Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
6ddf34da
Commit
6ddf34da
authored
Dec 15, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
828fb61b
c027101d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
20 deletions
+20
-20
app/helpers/version_check_helper.rb
app/helpers/version_check_helper.rb
+1
-2
lib/version_check.rb
lib/version_check.rb
+4
-3
spec/features/help_pages_spec.rb
spec/features/help_pages_spec.rb
+9
-9
spec/helpers/version_check_helper_spec.rb
spec/helpers/version_check_helper_spec.rb
+6
-6
No files found.
app/helpers/version_check_helper.rb
View file @
6ddf34da
...
@@ -6,8 +6,7 @@ module VersionCheckHelper
...
@@ -6,8 +6,7 @@ module VersionCheckHelper
return
unless
Gitlab
::
CurrentSettings
.
version_check_enabled
return
unless
Gitlab
::
CurrentSettings
.
version_check_enabled
return
if
User
.
single_user
&
.
requires_usage_stats_consent?
return
if
User
.
single_user
&
.
requires_usage_stats_consent?
image_url
=
VersionCheck
.
new
.
url
image_tag
VersionCheck
.
url
,
class:
'js-version-status-badge'
image_tag
image_url
,
class:
'js-version-status-badge'
end
end
def
link_to_version
def
link_to_version
...
...
lib/version_check.rb
View file @
6ddf34da
...
@@ -5,16 +5,17 @@ require "base64"
...
@@ -5,16 +5,17 @@ require "base64"
# This class is used to build image URL to
# This class is used to build image URL to
# check if it is a new version for update
# check if it is a new version for update
class
VersionCheck
class
VersionCheck
def
data
def
self
.
data
{
version:
Gitlab
::
VERSION
}
{
version:
Gitlab
::
VERSION
}
end
end
def
url
def
self
.
url
encoded_data
=
Base64
.
urlsafe_encode64
(
data
.
to_json
)
encoded_data
=
Base64
.
urlsafe_encode64
(
data
.
to_json
)
"
#{
host
}
?gitlab_info=
#{
encoded_data
}
"
"
#{
host
}
?gitlab_info=
#{
encoded_data
}
"
end
end
def
host
def
self
.
host
'https://version.gitlab.com/check.svg'
'https://version.gitlab.com/check.svg'
end
end
end
end
spec/features/help_pages_spec.rb
View file @
6ddf34da
# frozen_string_literal: true
require
'spec_helper'
require
'spec_helper'
describe
'Help Pages'
do
describe
'Help Pages'
do
...
@@ -52,23 +54,21 @@ describe 'Help Pages' do
...
@@ -52,23 +54,21 @@ describe 'Help Pages' do
end
end
end
end
context
'in a production environment with version check enabled'
,
:js
do
context
'in a production environment with version check enabled'
do
before
do
before
do
allow
(
Rails
.
env
).
to
receive
(
:production?
)
{
true
}
stub_application_setting
(
version_check_enabled:
true
)
stub_application_setting
(
version_check_enabled:
true
)
allow_any_instance_of
(
VersionCheck
).
to
receive
(
:url
)
{
'/version-check-url'
}
allow
(
Rails
.
env
).
to
receive
(
:production?
).
and_return
(
true
)
allow
(
VersionCheck
).
to
receive
(
:url
).
and_return
(
'/version-check-url'
)
sign_in
(
create
(
:user
))
sign_in
(
create
(
:user
))
visit
help_path
visit
help_path
end
end
it
'has a version check image'
do
it
'has a version check image'
do
expect
(
find
(
'.js-version-status-badge'
,
visible:
false
)[
'src'
]).
to
end_with
(
'/version-check-url'
)
# Check `data-src` due to lazy image loading
end
expect
(
find
(
'.js-version-status-badge'
,
visible:
false
)[
'data-src'
])
.
to
end_with
(
'/version-check-url'
)
it
'hides the version check image if the image request fails'
do
# We use '--load-images=yes' with poltergeist so the image fails to load
expect
(
page
).
to
have_selector
(
'.js-version-status-badge'
,
visible:
false
)
end
end
end
end
...
...
spec/helpers/version_check_helper_spec.rb
View file @
6ddf34da
...
@@ -13,21 +13,21 @@ describe VersionCheckHelper do
...
@@ -13,21 +13,21 @@ describe VersionCheckHelper do
before
do
before
do
allow
(
Rails
.
env
).
to
receive
(
:production?
)
{
true
}
allow
(
Rails
.
env
).
to
receive
(
:production?
)
{
true
}
allow
(
Gitlab
::
CurrentSettings
.
current_application_settings
).
to
receive
(
:version_check_enabled
)
{
true
}
allow
(
Gitlab
::
CurrentSettings
.
current_application_settings
).
to
receive
(
:version_check_enabled
)
{
true
}
allow_any_instance_of
(
VersionCheck
).
to
receive
(
:url
)
{
'https://version.host.com/check.svg?gitlab_info=xxx'
}
allow
(
VersionCheck
).
to
receive
(
:url
)
{
'https://version.host.com/check.svg?gitlab_info=xxx'
}
@image_tag
=
helper
.
version_status_badge
end
end
it
'should return an image tag'
do
it
'should return an image tag'
do
expect
(
@image_tag
).
to
match
(
/^<img/
)
expect
(
helper
.
version_status_badge
).
to
start_with
(
'<img'
)
end
end
it
'should have a js prefixed css class'
do
it
'should have a js prefixed css class'
do
expect
(
@image_tag
).
to
match
(
/class="js-version-status-badge lazy"/
)
expect
(
helper
.
version_status_badge
)
.
to
match
(
/class="js-version-status-badge lazy"/
)
end
end
it
'should have a VersionCheck url as the src'
do
it
'should have a VersionCheck url as the src'
do
expect
(
@image_tag
).
to
match
(
%r{src="https://version
\.
host
\.
com/check
\.
svg
\?
gitlab_info=xxx"}
)
expect
(
helper
.
version_status_badge
)
.
to
include
(
%{src="https://version.host.com/check.svg?gitlab_info=xxx"}
)
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment