summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-09-16 14:32:43 +0100
committerPhil Hughes <me@iamphill.com>2016-10-06 10:17:34 +0100
commit97dc95b18e5a5c29daab84e0d65522b3d3158dc1 (patch)
tree7520b6a7dc674e8fdcce8e6f032874f4f2b20552
parent8962a3359c4282c755fff0fa08deeb64d74543a0 (diff)
downloadgitlab-ce-97dc95b18e5a5c29daab84e0d65522b3d3158dc1.tar.gz
Fixed tests
-rw-r--r--app/assets/javascripts/merge_request_tabs.js15
-rw-r--r--spec/features/merge_requests/sticky_tabs_spec.rb10
2 files changed, 16 insertions, 9 deletions
diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js
index f685af7d97e..1a214cdd00e 100644
--- a/app/assets/javascripts/merge_request_tabs.js
+++ b/app/assets/javascripts/merge_request_tabs.js
@@ -369,18 +369,21 @@
};
MergeRequestTabs.prototype.initAffix = function () {
+ var $tabs = $('.js-tabs-affix');
+
// Screen space on small screens is usually very sparse
// So we dont affix the tabs on these
- if (Breakpoints.get().getBreakpointSize() === 'xs') return;
+ if (Breakpoints.get().getBreakpointSize() === 'xs' || !$tabs.length) return;
- var $tabs = $('.js-tabs-affix'),
- tabsWidth = $tabs.outerWidth(),
- $diffTabs = $('#diff-notes-app'),
- offsetTop = $tabs.offset().top - ($('.navbar-fixed-top').height() + $('.layout-nav').height());
+ var tabsWidth = $tabs.outerWidth(),
+ $diffTabs = $('#diff-notes-app'),
+ offsetTop = $tabs.offset().top - ($('.navbar-fixed-top').height() + $('.layout-nav').height());
$tabs.off('affix.bs.affix affix-top.bs.affix')
.affix({
- offset: offsetTop
+ offset: {
+ top: offsetTop
+ }
}).on('affix.bs.affix', function () {
$tabs.css({
left: $tabs.offset().left,
diff --git a/spec/features/merge_requests/sticky_tabs_spec.rb b/spec/features/merge_requests/sticky_tabs_spec.rb
index 6f8c3dc55f4..e78f3f134d5 100644
--- a/spec/features/merge_requests/sticky_tabs_spec.rb
+++ b/spec/features/merge_requests/sticky_tabs_spec.rb
@@ -1,6 +1,8 @@
require 'spec_helper'
feature 'Merge request tabs', js: true, feature: true do
+ include WaitForAjax
+
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user, title: "Bug NS-04") }
@@ -9,18 +11,20 @@ feature 'Merge request tabs', js: true, feature: true do
project.team << [user, :master]
login_as user
visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request)
+
+ wait_for_ajax
end
it 'affixes to top of page when scrolling' do
- page.execute_script "window.scrollBy(0,10000)"
+ page.execute_script "window.scroll(0,10000)"
expect(page).to have_selector('.js-tabs-affix.affix')
end
it 'removes affix when scrolling to top' do
- page.execute_script "window.scrollBy(0,10000)"
+ page.execute_script "window.scroll(0,10000)"
expect(page).to have_selector('.js-tabs-affix.affix')
- page.execute_script "window.scrollBy(0,-10000)"
+ page.execute_script "window.scroll(0,-10000)"
expect(page).to have_selector('.js-tabs-affix.affix-top')
end
end