Fixed tests

This commit is contained in:
Phil Hughes 2016-09-16 14:32:43 +01:00
parent 8962a3359c
commit 97dc95b18e
2 changed files with 16 additions and 9 deletions

View file

@ -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,

View file

@ -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