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
bb483230
Commit
bb483230
authored
Jan 12, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added specs for version check image
parent
7bf28a4a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
105 additions
and
9 deletions
+105
-9
app/assets/javascripts/version_check_image.js.es6
app/assets/javascripts/version_check_image.js.es6
+8
-8
spec/features/help_pages_spec.rb
spec/features/help_pages_spec.rb
+26
-0
spec/helpers/version_check_helper_spec.rb
spec/helpers/version_check_helper_spec.rb
+34
-0
spec/javascripts/.eslintrc
spec/javascripts/.eslintrc
+2
-1
spec/javascripts/helpers/class_spec_helper.js.es6
spec/javascripts/helpers/class_spec_helper.js.es6
+2
-0
spec/javascripts/version_check_image_spec.js.es6
spec/javascripts/version_check_image_spec.js.es6
+33
-0
No files found.
app/assets/javascripts/version_check_image.js.es6
View file @
bb483230
(() => {
class VersionCheckImage {
class VersionCheckImage {
static bindErrorEvent(imageElement) {
static bindErrorEvent(imageElement) {
imageElement.off('error').on('error', () => imageElement.hide());
imageElement.off('error').on('error', () => imageElement.hide());
}
}
}
}
window.gl = window.gl || {};
gl.VersionCheckImage = VersionCheckImage;
window.gl = window.gl || {};
module.exports = VersionCheckImage;
gl.VersionCheckImage = VersionCheckImage;
})();
spec/features/help_pages_spec.rb
View file @
bb483230
...
@@ -33,4 +33,30 @@ describe 'Help Pages', feature: true do
...
@@ -33,4 +33,30 @@ describe 'Help Pages', feature: true do
it_behaves_like
'help page'
,
prefix:
'/gitlab'
it_behaves_like
'help page'
,
prefix:
'/gitlab'
end
end
end
end
context
'in a production environment with version check enabled'
,
js:
true
do
before
do
allow
(
Rails
.
env
).
to
receive
(
:production?
)
{
true
}
allow
(
current_application_settings
).
to
receive
(
:version_check_enabled
)
{
true
}
allow_any_instance_of
(
VersionCheck
).
to
receive
(
:url
)
{
'/version-check-url'
}
login_as
:user
visit
help_path
end
it
'should display a version check image'
do
expect
(
find
(
'.js-version-status-badge'
)).
to
be_visible
end
it
'should have a src url'
do
expect
(
find
(
'.js-version-status-badge'
)[
'src'
]).
to
match
(
/\/version-check-url/
)
end
it
'should hide the version check image if the image request fails'
do
# We use '--load-images=no' with poltergeist so we must trigger manually
execute_script
(
"$('.js-version-status-badge').trigger('error');"
)
expect
(
find
(
'.js-version-status-badge'
,
visible:
false
)).
not_to
be_visible
end
end
end
end
spec/helpers/version_check_helper_spec.rb
0 → 100644
View file @
bb483230
require
'spec_helper'
describe
VersionCheckHelper
do
describe
'#version_status_badge'
do
it
'should return nil if not dev environment and not enabled'
do
allow
(
Rails
.
env
).
to
receive
(
:production?
)
{
false
}
allow
(
current_application_settings
).
to
receive
(
:version_check_enabled
)
{
false
}
expect
(
helper
.
version_status_badge
).
to
be
(
nil
)
end
context
'when production and enabled'
do
before
do
allow
(
Rails
.
env
).
to
receive
(
:production?
)
{
true
}
allow
(
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'
}
@image_tag
=
helper
.
version_status_badge
end
it
'should return an image tag'
do
expect
(
@image_tag
).
to
match
(
/^<img/
)
end
it
'should have a js prefixed css class'
do
expect
(
@image_tag
).
to
match
(
/class="js-version-status-badge"/
)
end
it
'should have a VersionCheck url as the src'
do
expect
(
@image_tag
).
to
match
(
/src="https:\/\/version\.host\.com\/check\.svg\?gitlab_info=xxx"/
)
end
end
end
end
spec/javascripts/.eslintrc
View file @
bb483230
...
@@ -18,7 +18,8 @@
...
@@ -18,7 +18,8 @@
"sandbox": false,
"sandbox": false,
"setFixtures": false,
"setFixtures": false,
"setStyleFixtures": false,
"setStyleFixtures": false,
"spyOnEvent": false
"spyOnEvent": false,
"ClassSpecHelper": false
},
},
"plugins": ["jasmine"],
"plugins": ["jasmine"],
"rules": {
"rules": {
...
...
spec/javascripts/helpers/class_spec_helper.js.es6
View file @
bb483230
...
@@ -7,3 +7,5 @@ class ClassSpecHelper {
...
@@ -7,3 +7,5 @@ class ClassSpecHelper {
}
}
window.ClassSpecHelper = ClassSpecHelper;
window.ClassSpecHelper = ClassSpecHelper;
module.exports = ClassSpecHelper;
spec/javascripts/version_check_image_spec.js.es6
0 → 100644
View file @
bb483230
const ClassSpecHelper = require('./helpers/class_spec_helper');
const VersionCheckImage = require('~/version_check_image');
require('jquery');
describe('VersionCheckImage', function () {
describe('.bindErrorEvent', function () {
ClassSpecHelper.itShouldBeAStaticMethod(VersionCheckImage, 'bindErrorEvent');
beforeEach(function () {
this.imageElement = $('<div></div>');
});
it('registers an error event', function () {
spyOn($.prototype, 'on');
spyOn($.prototype, 'off').and.callFake(function () { return this; });
VersionCheckImage.bindErrorEvent(this.imageElement);
expect($.prototype.off).toHaveBeenCalledWith('error');
expect($.prototype.on).toHaveBeenCalledWith('error', jasmine.any(Function));
});
it('hides the imageElement on error', function () {
spyOn($.prototype, 'hide');
VersionCheckImage.bindErrorEvent(this.imageElement);
this.imageElement.trigger('error');
expect($.prototype.hide).toHaveBeenCalled();
});
});
});
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