From dccf8a9fc8d4dde91942944f6b47387bfb13c380 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Mon, 25 Apr 2016 20:10:20 +0200 Subject: Add tests on Awardables and Award Emoji --- spec/features/issues_spec.rb | 2 +- spec/features/notes_on_merge_requests_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'spec/features') diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index 1ce0024e93c..7da87c2d174 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -67,7 +67,7 @@ describe 'Issues', feature: true do describe 'Issue info' do it 'excludes award_emoji from comment count' do issue = create(:issue, author: @user, assignee: @user, project: project, title: 'foobar') - create(:upvote_note, noteable: issue) + create(:award_emoji, awardable: issue) visit namespace_project_issues_path(project.namespace, project, assignee_id: @user.id) diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb index 389812ff7e1..9e2bdd7f5bb 100644 --- a/spec/features/notes_on_merge_requests_spec.rb +++ b/spec/features/notes_on_merge_requests_spec.rb @@ -8,7 +8,7 @@ describe 'Comments', feature: true do it 'excludes award_emoji from comment count' do merge_request = create(:merge_request) project = merge_request.source_project - create(:upvote_note, noteable: merge_request, project: project) + create(:award_emoji, awardable: merge_request, project: project) login_as :admin visit namespace_project_merge_requests_path(project.namespace, project) @@ -146,7 +146,7 @@ describe 'Comments', feature: true do describe 'comment info' do it 'excludes award_emoji from comment count' do - create(:upvote_note, noteable: merge_request, project: project) + create(:award_emoji, awardable: merge_request, project: project) visit namespace_project_merge_request_path(project.namespace, project, merge_request) -- cgit v1.2.1 From 4558b5b9fe9f648903ad0dc01089e6118fe0af34 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Wed, 11 May 2016 22:43:58 +0200 Subject: Incorporate feedback --- spec/features/issues/award_emoji_spec.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'spec/features') diff --git a/spec/features/issues/award_emoji_spec.rb b/spec/features/issues/award_emoji_spec.rb index 41af789aae2..07a854ea014 100644 --- a/spec/features/issues/award_emoji_spec.rb +++ b/spec/features/issues/award_emoji_spec.rb @@ -28,7 +28,6 @@ describe 'Awards Emoji', feature: true do end context 'click the thumbsup emoji' do - it 'should increment the thumbsup emoji', js: true do find('[data-emoji="thumbsup"]').click sleep 2 @@ -41,7 +40,6 @@ describe 'Awards Emoji', feature: true do end context 'click the thumbsdown emoji' do - it 'should increment the thumbsdown emoji', js: true do find('[data-emoji="thumbsdown"]').click sleep 2 -- cgit v1.2.1 From e0cabb67d0492907e6cef21bb0ef21a6e953b70b Mon Sep 17 00:00:00 2001 From: ZJ van de Weg Date: Tue, 17 May 2016 12:28:17 -0500 Subject: Fix latests concerns --- spec/features/notes_on_merge_requests_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'spec/features') diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb index 9e2bdd7f5bb..c93497970d7 100644 --- a/spec/features/notes_on_merge_requests_spec.rb +++ b/spec/features/notes_on_merge_requests_spec.rb @@ -8,12 +8,12 @@ describe 'Comments', feature: true do it 'excludes award_emoji from comment count' do merge_request = create(:merge_request) project = merge_request.source_project - create(:award_emoji, awardable: merge_request, project: project) + create(:award_emoji, awardable: merge_request) login_as :admin visit namespace_project_merge_requests_path(project.namespace, project) - expect(merge_request.mr_and_commit_notes.count).to eq 1 + expect(merge_request.mr_and_commit_notes.count).to eq 0 expect(page.all('.merge-request-no-comments').first.text).to eq "0" end end @@ -146,11 +146,11 @@ describe 'Comments', feature: true do describe 'comment info' do it 'excludes award_emoji from comment count' do - create(:award_emoji, awardable: merge_request, project: project) + create(:award_emoji, awardable: merge_request) visit namespace_project_merge_request_path(project.namespace, project, merge_request) - expect(merge_request.mr_and_commit_notes.count).to eq 2 + expect(merge_request.mr_and_commit_notes.count).to eq 1 expect(find('.notes-tab span.badge').text).to eq "1" end end -- cgit v1.2.1 From 44876032a2d6511060ac484259355b328b89ac0a Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 1 Apr 2016 17:25:28 +0100 Subject: Added tests for issues --- spec/features/issues/award_spec.rb | 140 +++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 spec/features/issues/award_spec.rb (limited to 'spec/features') diff --git a/spec/features/issues/award_spec.rb b/spec/features/issues/award_spec.rb new file mode 100644 index 00000000000..46e1ed5d8cd --- /dev/null +++ b/spec/features/issues/award_spec.rb @@ -0,0 +1,140 @@ +require 'rails_helper' + +feature 'Issue awards', js: true, feature: true do + let(:user) { create(:user) } + let(:project) { create(:project, :public) } + let(:issue) { create(:issue, project: project) } + let!(:note) { create(:note_on_issue, project: project, noteable: issue, note: 'Looks good!') } + + describe 'logged in' do + before do + login_as(user) + visit namespace_project_issue_path(project.namespace, project, issue) + end + + it 'should add award to issue' do + first('.js-emoji-btn').click + expect(page).to have_selector('.js-emoji-btn.active') + expect(first('.js-emoji-btn')).to have_content '1' + end + + it 'should remove award from issue' do + first('.js-emoji-btn').click + find('.js-emoji-btn.active').click + expect(first('.js-emoji-btn')).to have_content '0' + end + + it 'should show award menu button in notes' do + page.within('.note') do + expect(page).to have_selector('.js-award-action-btn') + end + end + + it 'should not show award bar on note if no awards given' do + page.within('.note') do + expect(find('.js-awards-block', visible: false)).not_to be_visible + end + end + + it 'should be able to show award menu when clicking add award button in note' do + show_note_award_menu + end + + it 'should only have one menu on the page' do + first('.js-add-award').click + expect(page).to have_selector('.emoji-menu') + + page.within('.note') do + find('.js-add-award').click + expect(page).to have_selector('.emoji-menu', count: 1) + end + end + + it 'should add award to note' do + show_note_award_menu + award_on_note + + page.within('.note') do + expect(find('.js-awards-block')).to be_visible + expect(find('.js-awards-block')).to have_selector('.active') + end + end + + it 'should remove award from note' do + show_note_award_menu + award_on_note + + page.within('.note') do + expect(find('.js-awards-block')).to be_visible + expect(find('.js-awards-block')).to have_selector('.active') + end + + remove_award_on_note + sleep 0.5 + + page.within('.note') do + expect(find('.js-awards-block', visible: false)).not_to be_visible + expect(find('.js-awards-block', visible: false)).not_to have_selector('.active') + end + end + + it 'should not hide award bar on notes with more than 1 award' do + show_note_award_menu + award_on_note + + show_note_award_menu + award_on_note(2) + + page.within('.note') do + expect(find('.js-awards-block')).to be_visible + expect(find('.js-awards-block')).to have_selector('.active') + end + + remove_award_on_note + + page.within('.note') do + expect(find('.js-awards-block')).to be_visible + end + end + end + + describe 'logged out' do + before do + visit namespace_project_issue_path(project.namespace, project, issue) + end + + it 'should not see award menu button' do + expect(page).not_to have_selector('.js-award-holder') + end + + it 'should not see award menu button in note' do + page.within('.note') do + expect(page).not_to have_selector('.js-award-action-btn') + end + end + end + + def show_note_award_menu + page.within('.note') do + find('.js-add-award').click + expect(page).to have_selector('.emoji-menu') + end + end + + def award_on_note(index = 1) + page.within('.note') do + page.within('.emoji-menu') do + buttons = all('.js-emoji-btn') + buttons[index].click + end + end + end + + def remove_award_on_note + page.within('.note') do + page.within('.js-awards-block') do + first('.js-emoji-btn').click + end + end + end +end -- cgit v1.2.1 From bf96c30510c0efcd56338f60c902b5b64cf98bad Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 1 Apr 2016 17:35:10 +0100 Subject: Award spec for merge requests --- spec/features/merge_requests/award_spec.rb | 140 +++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 spec/features/merge_requests/award_spec.rb (limited to 'spec/features') diff --git a/spec/features/merge_requests/award_spec.rb b/spec/features/merge_requests/award_spec.rb new file mode 100644 index 00000000000..91e76e83c6f --- /dev/null +++ b/spec/features/merge_requests/award_spec.rb @@ -0,0 +1,140 @@ +require 'rails_helper' + +feature 'Merge request awards', js: true, feature: true do + let(:user) { create(:user) } + let(:project) { create(:project, :public) } + let(:merge_request) { create(:merge_request_with_diffs, source_project: project) } + let!(:note) { create(:note_on_merge_request, project: project, noteable: merge_request, note: 'Looks good!') } + + describe 'logged in' do + before do + login_as(user) + visit namespace_project_merge_request_path(project.namespace, project, merge_request) + end + + it 'should add award to merge request' do + first('.js-emoji-btn').click + expect(page).to have_selector('.js-emoji-btn.active') + expect(first('.js-emoji-btn')).to have_content '1' + end + + it 'should remove award from merge request' do + first('.js-emoji-btn').click + find('.js-emoji-btn.active').click + expect(first('.js-emoji-btn')).to have_content '0' + end + + it 'should show award menu button in notes' do + page.within('.note') do + expect(page).to have_selector('.js-award-action-btn') + end + end + + it 'should not show award bar on note if no awards given' do + page.within('.note') do + expect(find('.js-awards-block', visible: false)).not_to be_visible + end + end + + it 'should be able to show award menu when clicking add award button in note' do + show_note_award_menu + end + + it 'should only have one menu on the page' do + first('.js-add-award').click + expect(page).to have_selector('.emoji-menu') + + page.within('.note') do + find('.js-add-award').click + expect(page).to have_selector('.emoji-menu', count: 1) + end + end + + it 'should add award to note' do + show_note_award_menu + award_on_note + + page.within('.note') do + expect(find('.js-awards-block')).to be_visible + expect(find('.js-awards-block')).to have_selector('.active') + end + end + + it 'should remove award from note' do + show_note_award_menu + award_on_note + + page.within('.note') do + expect(find('.js-awards-block')).to be_visible + expect(find('.js-awards-block')).to have_selector('.active') + end + + remove_award_on_note + sleep 0.5 + + page.within('.note') do + expect(find('.js-awards-block', visible: false)).not_to be_visible + expect(find('.js-awards-block', visible: false)).not_to have_selector('.active') + end + end + + it 'should not hide award bar on notes with more than 1 award' do + show_note_award_menu + award_on_note + + show_note_award_menu + award_on_note(2) + + page.within('.note') do + expect(find('.js-awards-block')).to be_visible + expect(find('.js-awards-block')).to have_selector('.active') + end + + remove_award_on_note + + page.within('.note') do + expect(find('.js-awards-block')).to be_visible + end + end + end + + describe 'logged out' do + before do + visit namespace_project_merge_request_path(project.namespace, project, merge_request) + end + + it 'should not see award menu button' do + expect(page).not_to have_selector('.js-award-holder') + end + + it 'should not see award menu button in note' do + page.within('.note') do + expect(page).not_to have_selector('.js-award-action-btn') + end + end + end + + def show_note_award_menu + page.within('.note') do + find('.js-add-award').click + expect(page).to have_selector('.emoji-menu') + end + end + + def award_on_note(index = 1) + page.within('.note') do + page.within('.emoji-menu') do + buttons = all('.js-emoji-btn') + buttons[index].click + end + end + end + + def remove_award_on_note + page.within('.note') do + page.within('.js-awards-block') do + first('.js-emoji-btn').click + end + end + end +end -- cgit v1.2.1 From 783a5ae98c17ffd1d93e2e5390e543e5f2f92bcc Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 1 Apr 2016 18:18:45 +0100 Subject: Adds the emoji menu to the body and then re-positions it depending on which button clicked This spots bugs where the menu could be in a div that has overflow hidden on ie. diff comments --- spec/features/issues/award_spec.rb | 13 ++++++------- spec/features/merge_requests/award_spec.rb | 13 ++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) (limited to 'spec/features') diff --git a/spec/features/issues/award_spec.rb b/spec/features/issues/award_spec.rb index 46e1ed5d8cd..209d1cca176 100644 --- a/spec/features/issues/award_spec.rb +++ b/spec/features/issues/award_spec.rb @@ -46,8 +46,9 @@ feature 'Issue awards', js: true, feature: true do page.within('.note') do find('.js-add-award').click - expect(page).to have_selector('.emoji-menu', count: 1) end + + expect(page).to have_selector('.emoji-menu', count: 1) end it 'should add award to note' do @@ -117,16 +118,14 @@ feature 'Issue awards', js: true, feature: true do def show_note_award_menu page.within('.note') do find('.js-add-award').click - expect(page).to have_selector('.emoji-menu') end + expect(page).to have_selector('.emoji-menu') end def award_on_note(index = 1) - page.within('.note') do - page.within('.emoji-menu') do - buttons = all('.js-emoji-btn') - buttons[index].click - end + page.within('.emoji-menu') do + buttons = all('.js-emoji-btn') + buttons[index].click end end diff --git a/spec/features/merge_requests/award_spec.rb b/spec/features/merge_requests/award_spec.rb index 91e76e83c6f..0f268bab5da 100644 --- a/spec/features/merge_requests/award_spec.rb +++ b/spec/features/merge_requests/award_spec.rb @@ -46,8 +46,9 @@ feature 'Merge request awards', js: true, feature: true do page.within('.note') do find('.js-add-award').click - expect(page).to have_selector('.emoji-menu', count: 1) end + + expect(page).to have_selector('.emoji-menu', count: 1) end it 'should add award to note' do @@ -117,16 +118,14 @@ feature 'Merge request awards', js: true, feature: true do def show_note_award_menu page.within('.note') do find('.js-add-award').click - expect(page).to have_selector('.emoji-menu') end + expect(page).to have_selector('.emoji-menu') end def award_on_note(index = 1) - page.within('.note') do - page.within('.emoji-menu') do - buttons = all('.js-emoji-btn') - buttons[index].click - end + page.within('.emoji-menu') do + buttons = all('.js-emoji-btn') + buttons[index].click end end -- cgit v1.2.1 From f99b38c9d5dab11677b2680a671c1a66fb69283b Mon Sep 17 00:00:00 2001 From: ZJ van de Weg Date: Wed, 25 May 2016 21:27:36 +0200 Subject: Remove tests specific for awards on notes --- spec/features/issues/award_spec.rb | 67 ------------------------------ spec/features/merge_requests/award_spec.rb | 67 ------------------------------ 2 files changed, 134 deletions(-) (limited to 'spec/features') diff --git a/spec/features/issues/award_spec.rb b/spec/features/issues/award_spec.rb index 209d1cca176..eafd517c840 100644 --- a/spec/features/issues/award_spec.rb +++ b/spec/features/issues/award_spec.rb @@ -24,79 +24,12 @@ feature 'Issue awards', js: true, feature: true do expect(first('.js-emoji-btn')).to have_content '0' end - it 'should show award menu button in notes' do - page.within('.note') do - expect(page).to have_selector('.js-award-action-btn') - end - end - - it 'should not show award bar on note if no awards given' do - page.within('.note') do - expect(find('.js-awards-block', visible: false)).not_to be_visible - end - end - - it 'should be able to show award menu when clicking add award button in note' do - show_note_award_menu - end - it 'should only have one menu on the page' do first('.js-add-award').click expect(page).to have_selector('.emoji-menu') - page.within('.note') do - find('.js-add-award').click - end - expect(page).to have_selector('.emoji-menu', count: 1) end - - it 'should add award to note' do - show_note_award_menu - award_on_note - - page.within('.note') do - expect(find('.js-awards-block')).to be_visible - expect(find('.js-awards-block')).to have_selector('.active') - end - end - - it 'should remove award from note' do - show_note_award_menu - award_on_note - - page.within('.note') do - expect(find('.js-awards-block')).to be_visible - expect(find('.js-awards-block')).to have_selector('.active') - end - - remove_award_on_note - sleep 0.5 - - page.within('.note') do - expect(find('.js-awards-block', visible: false)).not_to be_visible - expect(find('.js-awards-block', visible: false)).not_to have_selector('.active') - end - end - - it 'should not hide award bar on notes with more than 1 award' do - show_note_award_menu - award_on_note - - show_note_award_menu - award_on_note(2) - - page.within('.note') do - expect(find('.js-awards-block')).to be_visible - expect(find('.js-awards-block')).to have_selector('.active') - end - - remove_award_on_note - - page.within('.note') do - expect(find('.js-awards-block')).to be_visible - end - end end describe 'logged out' do diff --git a/spec/features/merge_requests/award_spec.rb b/spec/features/merge_requests/award_spec.rb index 0f268bab5da..4d3e8173ebe 100644 --- a/spec/features/merge_requests/award_spec.rb +++ b/spec/features/merge_requests/award_spec.rb @@ -24,79 +24,12 @@ feature 'Merge request awards', js: true, feature: true do expect(first('.js-emoji-btn')).to have_content '0' end - it 'should show award menu button in notes' do - page.within('.note') do - expect(page).to have_selector('.js-award-action-btn') - end - end - - it 'should not show award bar on note if no awards given' do - page.within('.note') do - expect(find('.js-awards-block', visible: false)).not_to be_visible - end - end - - it 'should be able to show award menu when clicking add award button in note' do - show_note_award_menu - end - it 'should only have one menu on the page' do first('.js-add-award').click expect(page).to have_selector('.emoji-menu') - page.within('.note') do - find('.js-add-award').click - end - expect(page).to have_selector('.emoji-menu', count: 1) end - - it 'should add award to note' do - show_note_award_menu - award_on_note - - page.within('.note') do - expect(find('.js-awards-block')).to be_visible - expect(find('.js-awards-block')).to have_selector('.active') - end - end - - it 'should remove award from note' do - show_note_award_menu - award_on_note - - page.within('.note') do - expect(find('.js-awards-block')).to be_visible - expect(find('.js-awards-block')).to have_selector('.active') - end - - remove_award_on_note - sleep 0.5 - - page.within('.note') do - expect(find('.js-awards-block', visible: false)).not_to be_visible - expect(find('.js-awards-block', visible: false)).not_to have_selector('.active') - end - end - - it 'should not hide award bar on notes with more than 1 award' do - show_note_award_menu - award_on_note - - show_note_award_menu - award_on_note(2) - - page.within('.note') do - expect(find('.js-awards-block')).to be_visible - expect(find('.js-awards-block')).to have_selector('.active') - end - - remove_award_on_note - - page.within('.note') do - expect(find('.js-awards-block')).to be_visible - end - end end describe 'logged out' do -- cgit v1.2.1 From 91a7b9333b660abc866e52e1a614151cb529413d Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Wed, 1 Jun 2016 11:23:09 +0200 Subject: Incorportate feedback --- spec/features/issues/award_spec.rb | 35 +++++-------------------- spec/features/merge_requests/award_spec.rb | 37 +++++---------------------- spec/features/notes_on_merge_requests_spec.rb | 25 ------------------ 3 files changed, 13 insertions(+), 84 deletions(-) (limited to 'spec/features') diff --git a/spec/features/issues/award_spec.rb b/spec/features/issues/award_spec.rb index eafd517c840..63efecf8780 100644 --- a/spec/features/issues/award_spec.rb +++ b/spec/features/issues/award_spec.rb @@ -4,7 +4,6 @@ feature 'Issue awards', js: true, feature: true do let(:user) { create(:user) } let(:project) { create(:project, :public) } let(:issue) { create(:issue, project: project) } - let!(:note) { create(:note_on_issue, project: project, noteable: issue, note: 'Looks good!') } describe 'logged in' do before do @@ -16,12 +15,18 @@ feature 'Issue awards', js: true, feature: true do first('.js-emoji-btn').click expect(page).to have_selector('.js-emoji-btn.active') expect(first('.js-emoji-btn')).to have_content '1' + + visit namespace_project_issue_path(project.namespace, project, issue) + expect(first('.js-emoji-btn')).to have_content '1' end it 'should remove award from issue' do first('.js-emoji-btn').click find('.js-emoji-btn.active').click expect(first('.js-emoji-btn')).to have_content '0' + + visit namespace_project_issue_path(project.namespace, project, issue) + expect(first('.js-emoji-btn')).to have_content '0' end it 'should only have one menu on the page' do @@ -40,33 +45,5 @@ feature 'Issue awards', js: true, feature: true do it 'should not see award menu button' do expect(page).not_to have_selector('.js-award-holder') end - - it 'should not see award menu button in note' do - page.within('.note') do - expect(page).not_to have_selector('.js-award-action-btn') - end - end - end - - def show_note_award_menu - page.within('.note') do - find('.js-add-award').click - end - expect(page).to have_selector('.emoji-menu') - end - - def award_on_note(index = 1) - page.within('.emoji-menu') do - buttons = all('.js-emoji-btn') - buttons[index].click - end - end - - def remove_award_on_note - page.within('.note') do - page.within('.js-awards-block') do - first('.js-emoji-btn').click - end - end end end diff --git a/spec/features/merge_requests/award_spec.rb b/spec/features/merge_requests/award_spec.rb index 4d3e8173ebe..007f67d6080 100644 --- a/spec/features/merge_requests/award_spec.rb +++ b/spec/features/merge_requests/award_spec.rb @@ -3,8 +3,7 @@ require 'rails_helper' feature 'Merge request awards', js: true, feature: true do let(:user) { create(:user) } let(:project) { create(:project, :public) } - let(:merge_request) { create(:merge_request_with_diffs, source_project: project) } - let!(:note) { create(:note_on_merge_request, project: project, noteable: merge_request, note: 'Looks good!') } + let(:merge_request) { create(:merge_request, source_project: project) } describe 'logged in' do before do @@ -16,12 +15,18 @@ feature 'Merge request awards', js: true, feature: true do first('.js-emoji-btn').click expect(page).to have_selector('.js-emoji-btn.active') expect(first('.js-emoji-btn')).to have_content '1' + + visit namespace_project_merge_request_path(project.namespace, project, merge_request) + expect(first('.js-emoji-btn')).to have_content '1' end it 'should remove award from merge request' do first('.js-emoji-btn').click find('.js-emoji-btn.active').click expect(first('.js-emoji-btn')).to have_content '0' + + visit namespace_project_merge_request_path(project.namespace, project, merge_request) + expect(first('.js-emoji-btn')).to have_content '0' end it 'should only have one menu on the page' do @@ -40,33 +45,5 @@ feature 'Merge request awards', js: true, feature: true do it 'should not see award menu button' do expect(page).not_to have_selector('.js-award-holder') end - - it 'should not see award menu button in note' do - page.within('.note') do - expect(page).not_to have_selector('.js-award-action-btn') - end - end - end - - def show_note_award_menu - page.within('.note') do - find('.js-add-award').click - end - expect(page).to have_selector('.emoji-menu') - end - - def award_on_note(index = 1) - page.within('.emoji-menu') do - buttons = all('.js-emoji-btn') - buttons[index].click - end - end - - def remove_award_on_note - page.within('.note') do - page.within('.js-awards-block') do - first('.js-emoji-btn').click - end - end end end diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb index de52460f15f..737efcef45d 100644 --- a/spec/features/notes_on_merge_requests_spec.rb +++ b/spec/features/notes_on_merge_requests_spec.rb @@ -4,20 +4,6 @@ describe 'Comments', feature: true do include RepoHelpers include WaitForAjax - describe 'On merge requests page', feature: true do - it 'excludes award_emoji from comment count' do - merge_request = create(:merge_request) - project = merge_request.source_project - create(:award_emoji, awardable: merge_request) - - login_as :admin - visit namespace_project_merge_requests_path(project.namespace, project) - - expect(merge_request.mr_and_commit_notes.count).to eq 0 - expect(page.all('.merge-request-no-comments').first.text).to eq "0" - end - end - describe 'On a merge request', js: true, feature: true do let!(:project) { create(:project) } let!(:merge_request) do @@ -147,17 +133,6 @@ describe 'Comments', feature: true do end end end - - describe 'comment info' do - it 'excludes award_emoji from comment count' do - create(:award_emoji, awardable: merge_request) - - visit namespace_project_merge_request_path(project.namespace, project, merge_request) - - expect(merge_request.mr_and_commit_notes.count).to eq 1 - expect(find('.notes-tab span.badge').text).to eq "1" - end - end end describe 'On a merge request diff', js: true, feature: true do -- cgit v1.2.1 From 1abb0ed97d48b603f7488fe2543aeef110067908 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 2 Jun 2016 11:05:54 +0200 Subject: Move feature specs for shortcuts to valid directory --- spec/features/project/shortcuts_spec.rb | 21 --------------------- spec/features/projects/shortcuts_spec.rb | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-) delete mode 100644 spec/features/project/shortcuts_spec.rb create mode 100644 spec/features/projects/shortcuts_spec.rb (limited to 'spec/features') diff --git a/spec/features/project/shortcuts_spec.rb b/spec/features/project/shortcuts_spec.rb deleted file mode 100644 index 54aa9c66a08..00000000000 --- a/spec/features/project/shortcuts_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -feature 'Project shortcuts', feature: true do - let(:project) { create(:project, name: 'Victorialand') } - let(:user) { create(:user) } - - describe 'On a project', js: true do - before do - project.team << [user, :master] - login_as user - visit namespace_project_path(project.namespace, project) - end - - describe 'pressing "i"' do - it 'redirects to new issue page' do - find('body').native.send_key('i') - expect(page).to have_content('Victorialand') - end - end - end -end diff --git a/spec/features/projects/shortcuts_spec.rb b/spec/features/projects/shortcuts_spec.rb new file mode 100644 index 00000000000..54aa9c66a08 --- /dev/null +++ b/spec/features/projects/shortcuts_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +feature 'Project shortcuts', feature: true do + let(:project) { create(:project, name: 'Victorialand') } + let(:user) { create(:user) } + + describe 'On a project', js: true do + before do + project.team << [user, :master] + login_as user + visit namespace_project_path(project.namespace, project) + end + + describe 'pressing "i"' do + it 'redirects to new issue page' do + find('body').native.send_key('i') + expect(page).to have_content('Victorialand') + end + end + end +end -- cgit v1.2.1 From 021d3810c300d1e0514f21ccb6f1439f59e20565 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Thu, 2 Jun 2016 16:19:18 +0200 Subject: Rename Ci::Commit to Ci::Pipeline and rename some of the ci_commit to pipeline --- spec/features/pipelines_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/features') diff --git a/spec/features/pipelines_spec.rb b/spec/features/pipelines_spec.rb index acd6fb3538c..093f92ffc6d 100644 --- a/spec/features/pipelines_spec.rb +++ b/spec/features/pipelines_spec.rb @@ -167,7 +167,7 @@ describe "Pipelines" do context 'with gitlab-ci.yml' do before { stub_ci_commit_to_return_yaml_file } - it { expect{ click_on 'Create pipeline' }.to change{ Ci::Commit.count }.by(1) } + it { expect{ click_on 'Create pipeline' }.to change{ Ci::Pipeline.count }.by(1) } end context 'without gitlab-ci.yml' do -- cgit v1.2.1 From c3e923c496b7d1c344a5fa68cef4a80ce23c90d0 Mon Sep 17 00:00:00 2001 From: DJ Mountney Date: Wed, 25 May 2016 18:52:10 -0700 Subject: Ensure we don't show TODOS for projects pending delete By joining the Todos on the project table. --- spec/features/todos/todos_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'spec/features') diff --git a/spec/features/todos/todos_spec.rb b/spec/features/todos/todos_spec.rb index 4e627753cc7..c8c86a3ff47 100644 --- a/spec/features/todos/todos_spec.rb +++ b/spec/features/todos/todos_spec.rb @@ -98,5 +98,18 @@ describe 'Dashboard Todos', feature: true do end end end + + context 'User has a Todo in a project pending deletion' do + before do + deleted_project = create(:project, pending_delete: true) + create(:todo, :mentioned, user: user, project: deleted_project, target: issue, author: author) + login_as(user) + visit dashboard_todos_path + end + + it 'shows "All done" message' do + expect(page).to have_content "You're all done!" + end + end end end -- cgit v1.2.1 From b173ea2bd4bbc65529b827f9afa5999f6f04579e Mon Sep 17 00:00:00 2001 From: DJ Mountney Date: Wed, 1 Jun 2016 16:44:35 -0700 Subject: Use the project finder in the todos finder to limit todos to just ones within projects you have access to. --- spec/features/todos/todos_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/features') diff --git a/spec/features/todos/todos_spec.rb b/spec/features/todos/todos_spec.rb index c8c86a3ff47..c0a1cd64f32 100644 --- a/spec/features/todos/todos_spec.rb +++ b/spec/features/todos/todos_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'Dashboard Todos', feature: true do let(:user) { create(:user) } let(:author) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } let(:issue) { create(:issue) } describe 'GET /dashboard/todos' do -- cgit v1.2.1 From 14a9b0d7dda78e88852644bd9a6c05922b5e367d Mon Sep 17 00:00:00 2001 From: DJ Mountney Date: Thu, 2 Jun 2016 12:06:24 -0700 Subject: Update target todo test to use a public project --- spec/features/todos/target_state_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/features') diff --git a/spec/features/todos/target_state_spec.rb b/spec/features/todos/target_state_spec.rb index 72491ac7e61..32fa88a2b21 100644 --- a/spec/features/todos/target_state_spec.rb +++ b/spec/features/todos/target_state_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' feature 'Todo target states', feature: true do let(:user) { create(:user) } let(:author) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } before do login_as user -- cgit v1.2.1 From 86675194aa44236c3e9acc4aa7ede143f718685e Mon Sep 17 00:00:00 2001 From: DJ Mountney Date: Thu, 2 Jun 2016 15:30:13 -0700 Subject: Fix failing todo tests --- spec/features/todos/todos_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/features') diff --git a/spec/features/todos/todos_spec.rb b/spec/features/todos/todos_spec.rb index c0a1cd64f32..8e1833a069e 100644 --- a/spec/features/todos/todos_spec.rb +++ b/spec/features/todos/todos_spec.rb @@ -49,7 +49,7 @@ describe 'Dashboard Todos', feature: true do note1 = create(:note_on_issue, note: "Hello #{label1.to_reference(format: :name)}", noteable_id: issue.id, noteable_type: 'Issue', project: issue.project) create(:todo, :mentioned, project: project, target: issue, user: user, note_id: note1.id) - project2 = create(:project) + project2 = create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) label2 = create(:label, project: project2) issue2 = create(:issue, project: project2) note2 = create(:note_on_issue, note: "Test #{label2.to_reference(format: :name)}", noteable_id: issue2.id, noteable_type: 'Issue', project: project2) @@ -101,7 +101,7 @@ describe 'Dashboard Todos', feature: true do context 'User has a Todo in a project pending deletion' do before do - deleted_project = create(:project, pending_delete: true) + deleted_project = create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC, pending_delete: true) create(:todo, :mentioned, user: user, project: deleted_project, target: issue, author: author) login_as(user) visit dashboard_todos_path -- cgit v1.2.1 From 717fdd6d42f119dd1e0f457c40563cc35985fbae Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 3 Jun 2016 12:29:00 +0200 Subject: Rename Ci::Build commit to pipeline --- spec/features/admin/admin_builds_spec.rb | 24 +++++++++++----------- spec/features/admin/admin_runners_spec.rb | 2 +- spec/features/builds_spec.rb | 2 +- spec/features/commits_spec.rb | 4 ++-- .../merge_when_build_succeeds_spec.rb | 4 ++-- spec/features/pipelines_spec.rb | 20 +++++++++--------- .../security/project/public_access_spec.rb | 2 +- 7 files changed, 29 insertions(+), 29 deletions(-) (limited to 'spec/features') diff --git a/spec/features/admin/admin_builds_spec.rb b/spec/features/admin/admin_builds_spec.rb index 7bbe20fec43..f5aedcb0545 100644 --- a/spec/features/admin/admin_builds_spec.rb +++ b/spec/features/admin/admin_builds_spec.rb @@ -11,10 +11,10 @@ describe 'Admin Builds' do context 'All tab' do context 'when have builds' do it 'shows all builds' do - create(:ci_build, commit: commit, status: :pending) - create(:ci_build, commit: commit, status: :running) - create(:ci_build, commit: commit, status: :success) - create(:ci_build, commit: commit, status: :failed) + create(:ci_build, pipeline: commit, status: :pending) + create(:ci_build, pipeline: commit, status: :running) + create(:ci_build, pipeline: commit, status: :success) + create(:ci_build, pipeline: commit, status: :failed) visit admin_builds_path @@ -39,9 +39,9 @@ describe 'Admin Builds' do context 'Running tab' do context 'when have running builds' do it 'shows running builds' do - build1 = create(:ci_build, commit: commit, status: :pending) - build2 = create(:ci_build, commit: commit, status: :success) - build3 = create(:ci_build, commit: commit, status: :failed) + build1 = create(:ci_build, pipeline: commit, status: :pending) + build2 = create(:ci_build, pipeline: commit, status: :success) + build3 = create(:ci_build, pipeline: commit, status: :failed) visit admin_builds_path(scope: :running) @@ -55,7 +55,7 @@ describe 'Admin Builds' do context 'when have no builds running' do it 'shows a message' do - create(:ci_build, commit: commit, status: :success) + create(:ci_build, pipeline: commit, status: :success) visit admin_builds_path(scope: :running) @@ -69,9 +69,9 @@ describe 'Admin Builds' do context 'Finished tab' do context 'when have finished builds' do it 'shows finished builds' do - build1 = create(:ci_build, commit: commit, status: :pending) - build2 = create(:ci_build, commit: commit, status: :running) - build3 = create(:ci_build, commit: commit, status: :success) + build1 = create(:ci_build, pipeline: commit, status: :pending) + build2 = create(:ci_build, pipeline: commit, status: :running) + build3 = create(:ci_build, pipeline: commit, status: :success) visit admin_builds_path(scope: :finished) @@ -85,7 +85,7 @@ describe 'Admin Builds' do context 'when have no builds finished' do it 'shows a message' do - create(:ci_build, commit: commit, status: :running) + create(:ci_build, pipeline: commit, status: :running) visit admin_builds_path(scope: :finished) diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb index 8ebd4a6808e..2c87a25913b 100644 --- a/spec/features/admin/admin_runners_spec.rb +++ b/spec/features/admin/admin_runners_spec.rb @@ -9,7 +9,7 @@ describe "Admin Runners" do before do runner = FactoryGirl.create(:ci_runner) commit = FactoryGirl.create(:ci_commit) - FactoryGirl.create(:ci_build, commit: commit, runner_id: runner.id) + FactoryGirl.create(:ci_build, pipeline: commit, runner_id: runner.id) visit admin_runners_path end diff --git a/spec/features/builds_spec.rb b/spec/features/builds_spec.rb index 7a05d30e8b5..c1c21d4b786 100644 --- a/spec/features/builds_spec.rb +++ b/spec/features/builds_spec.rb @@ -6,7 +6,7 @@ describe "Builds" do before do login_as(:user) @commit = FactoryGirl.create :ci_commit - @build = FactoryGirl.create :ci_build, commit: @commit + @build = FactoryGirl.create :ci_build, pipeline: @commit @project = @commit.project @project.team << [@user, :developer] end diff --git a/spec/features/commits_spec.rb b/spec/features/commits_spec.rb index 20f0b27bcc1..d8f5a2f804f 100644 --- a/spec/features/commits_spec.rb +++ b/spec/features/commits_spec.rb @@ -16,7 +16,7 @@ describe 'Commits' do end context 'commit status is Generic Commit Status' do - let!(:status) { FactoryGirl.create :generic_commit_status, commit: commit } + let!(:status) { FactoryGirl.create :generic_commit_status, pipeline: commit } before do project.team << [@user, :reporter] @@ -39,7 +39,7 @@ describe 'Commits' do end context 'commit status is Ci Build' do - let!(:build) { FactoryGirl.create :ci_build, commit: commit } + let!(:build) { FactoryGirl.create :ci_build, pipeline: commit } let(:artifacts_file) { fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif') } context 'when logged as developer' do diff --git a/spec/features/merge_requests/merge_when_build_succeeds_spec.rb b/spec/features/merge_requests/merge_when_build_succeeds_spec.rb index 7aa7eb965e9..eaa3e6b1471 100644 --- a/spec/features/merge_requests/merge_when_build_succeeds_spec.rb +++ b/spec/features/merge_requests/merge_when_build_succeeds_spec.rb @@ -13,7 +13,7 @@ feature 'Merge When Build Succeeds', feature: true, js: true do context "Active build for Merge Request" do let!(:ci_commit) { create(:ci_commit, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch) } - let!(:ci_build) { create(:ci_build, commit: ci_commit) } + let!(:ci_build) { create(:ci_build, pipeline: ci_commit) } before do login_as user @@ -48,7 +48,7 @@ feature 'Merge When Build Succeeds', feature: true, js: true do end let!(:ci_commit) { create(:ci_commit, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch) } - let!(:ci_build) { create(:ci_build, commit: ci_commit) } + let!(:ci_build) { create(:ci_build, pipeline: ci_commit) } before do login_as user diff --git a/spec/features/pipelines_spec.rb b/spec/features/pipelines_spec.rb index 093f92ffc6d..2026cb7cf17 100644 --- a/spec/features/pipelines_spec.rb +++ b/spec/features/pipelines_spec.rb @@ -31,7 +31,7 @@ describe "Pipelines" do end context 'cancelable pipeline' do - let!(:running) { create(:ci_build, :running, commit: pipeline, stage: 'test', commands: 'test') } + let!(:running) { create(:ci_build, :running, pipeline: pipeline, stage: 'test', commands: 'test') } before { visit namespace_project_pipelines_path(project.namespace, project) } @@ -47,7 +47,7 @@ describe "Pipelines" do end context 'retryable pipelines' do - let!(:failed) { create(:ci_build, :failed, commit: pipeline, stage: 'test', commands: 'test') } + let!(:failed) { create(:ci_build, :failed, pipeline: pipeline, stage: 'test', commands: 'test') } before { visit namespace_project_pipelines_path(project.namespace, project) } @@ -64,7 +64,7 @@ describe "Pipelines" do context 'for generic statuses' do context 'when running' do - let!(:running) { create(:generic_commit_status, status: 'running', commit: pipeline, stage: 'test') } + let!(:running) { create(:generic_commit_status, status: 'running', pipeline: pipeline, stage: 'test') } before { visit namespace_project_pipelines_path(project.namespace, project) } @@ -78,7 +78,7 @@ describe "Pipelines" do end context 'when failed' do - let!(:running) { create(:generic_commit_status, status: 'failed', commit: pipeline, stage: 'test') } + let!(:running) { create(:generic_commit_status, status: 'failed', pipeline: pipeline, stage: 'test') } before { visit namespace_project_pipelines_path(project.namespace, project) } @@ -94,7 +94,7 @@ describe "Pipelines" do context 'downloadable pipelines' do context 'with artifacts' do - let!(:with_artifacts) { create(:ci_build, :artifacts, :success, commit: pipeline, name: 'rspec tests', stage: 'test') } + let!(:with_artifacts) { create(:ci_build, :artifacts, :success, pipeline: pipeline, name: 'rspec tests', stage: 'test') } before { visit namespace_project_pipelines_path(project.namespace, project) } @@ -103,7 +103,7 @@ describe "Pipelines" do end context 'without artifacts' do - let!(:without_artifacts) { create(:ci_build, :success, commit: pipeline, name: 'rspec', stage: 'test') } + let!(:without_artifacts) { create(:ci_build, :success, pipeline: pipeline, name: 'rspec', stage: 'test') } it { expect(page).not_to have_selector('.build-artifacts') } end @@ -114,10 +114,10 @@ describe "Pipelines" do let(:pipeline) { create(:ci_commit, project: project, ref: 'master') } before do - @success = create(:ci_build, :success, commit: pipeline, stage: 'build', name: 'build') - @failed = create(:ci_build, :failed, commit: pipeline, stage: 'test', name: 'test', commands: 'test') - @running = create(:ci_build, :running, commit: pipeline, stage: 'deploy', name: 'deploy') - @external = create(:generic_commit_status, status: 'success', commit: pipeline, name: 'jenkins', stage: 'external') + @success = create(:ci_build, :success, pipeline: pipeline, stage: 'build', name: 'build') + @failed = create(:ci_build, :failed, pipeline: pipeline, stage: 'test', name: 'test', commands: 'test') + @running = create(:ci_build, :running, pipeline: pipeline, stage: 'deploy', name: 'deploy') + @external = create(:generic_commit_status, status: 'success', pipeline: pipeline, name: 'jenkins', stage: 'external') end before { visit namespace_project_pipeline_path(project.namespace, project, pipeline) } diff --git a/spec/features/security/project/public_access_spec.rb b/spec/features/security/project/public_access_spec.rb index 4def4f99bc0..4ce367c3c6d 100644 --- a/spec/features/security/project/public_access_spec.rb +++ b/spec/features/security/project/public_access_spec.rb @@ -143,7 +143,7 @@ describe "Public Project Access", feature: true do describe "GET /:project_path/builds/:id" do let(:commit) { create(:ci_commit, project: project) } - let(:build) { create(:ci_build, commit: commit) } + let(:build) { create(:ci_build, pipeline: commit) } subject { namespace_project_build_path(project.namespace, project, build.id) } context "when allowed for public" do -- cgit v1.2.1 From 20c7144ed20bad499b878425d5fbab408ad066b5 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 3 Jun 2016 16:22:26 +0200 Subject: Rename all `[ci_]commit` to `[ci_]pipeline` in specs and features --- spec/features/admin/admin_builds_spec.rb | 26 +++++----- spec/features/admin/admin_runners_spec.rb | 4 +- spec/features/builds_spec.rb | 2 +- spec/features/commits_spec.rb | 56 +++++++++++----------- .../merge_requests/created_from_fork_spec.rb | 2 +- .../merge_when_build_succeeds_spec.rb | 6 +-- spec/features/pipelines_spec.rb | 6 +-- spec/features/projects/commit/builds_spec.rb | 2 +- .../security/project/public_access_spec.rb | 4 +- 9 files changed, 54 insertions(+), 54 deletions(-) (limited to 'spec/features') diff --git a/spec/features/admin/admin_builds_spec.rb b/spec/features/admin/admin_builds_spec.rb index f5aedcb0545..a6198389f04 100644 --- a/spec/features/admin/admin_builds_spec.rb +++ b/spec/features/admin/admin_builds_spec.rb @@ -6,15 +6,15 @@ describe 'Admin Builds' do end describe 'GET /admin/builds' do - let(:commit) { create(:ci_commit) } + let(:pipeline) { create(:ci_pipeline) } context 'All tab' do context 'when have builds' do it 'shows all builds' do - create(:ci_build, pipeline: commit, status: :pending) - create(:ci_build, pipeline: commit, status: :running) - create(:ci_build, pipeline: commit, status: :success) - create(:ci_build, pipeline: commit, status: :failed) + create(:ci_build, pipeline: pipeline, status: :pending) + create(:ci_build, pipeline: pipeline, status: :running) + create(:ci_build, pipeline: pipeline, status: :success) + create(:ci_build, pipeline: pipeline, status: :failed) visit admin_builds_path @@ -39,9 +39,9 @@ describe 'Admin Builds' do context 'Running tab' do context 'when have running builds' do it 'shows running builds' do - build1 = create(:ci_build, pipeline: commit, status: :pending) - build2 = create(:ci_build, pipeline: commit, status: :success) - build3 = create(:ci_build, pipeline: commit, status: :failed) + build1 = create(:ci_build, pipeline: pipeline, status: :pending) + build2 = create(:ci_build, pipeline: pipeline, status: :success) + build3 = create(:ci_build, pipeline: pipeline, status: :failed) visit admin_builds_path(scope: :running) @@ -55,7 +55,7 @@ describe 'Admin Builds' do context 'when have no builds running' do it 'shows a message' do - create(:ci_build, pipeline: commit, status: :success) + create(:ci_build, pipeline: pipeline, status: :success) visit admin_builds_path(scope: :running) @@ -69,9 +69,9 @@ describe 'Admin Builds' do context 'Finished tab' do context 'when have finished builds' do it 'shows finished builds' do - build1 = create(:ci_build, pipeline: commit, status: :pending) - build2 = create(:ci_build, pipeline: commit, status: :running) - build3 = create(:ci_build, pipeline: commit, status: :success) + build1 = create(:ci_build, pipeline: pipeline, status: :pending) + build2 = create(:ci_build, pipeline: pipeline, status: :running) + build3 = create(:ci_build, pipeline: pipeline, status: :success) visit admin_builds_path(scope: :finished) @@ -85,7 +85,7 @@ describe 'Admin Builds' do context 'when have no builds finished' do it 'shows a message' do - create(:ci_build, pipeline: commit, status: :running) + create(:ci_build, pipeline: pipeline, status: :running) visit admin_builds_path(scope: :finished) diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb index 2c87a25913b..9499cd4e025 100644 --- a/spec/features/admin/admin_runners_spec.rb +++ b/spec/features/admin/admin_runners_spec.rb @@ -8,8 +8,8 @@ describe "Admin Runners" do describe "Runners page" do before do runner = FactoryGirl.create(:ci_runner) - commit = FactoryGirl.create(:ci_commit) - FactoryGirl.create(:ci_build, pipeline: commit, runner_id: runner.id) + pipeline = FactoryGirl.create(:ci_pipeline) + FactoryGirl.create(:ci_build, pipeline: pipeline, runner_id: runner.id) visit admin_runners_path end diff --git a/spec/features/builds_spec.rb b/spec/features/builds_spec.rb index c1c21d4b786..19bc0678814 100644 --- a/spec/features/builds_spec.rb +++ b/spec/features/builds_spec.rb @@ -5,7 +5,7 @@ describe "Builds" do before do login_as(:user) - @commit = FactoryGirl.create :ci_commit + @commit = FactoryGirl.create :ci_pipeline @build = FactoryGirl.create :ci_build, pipeline: @commit @project = @commit.project @project.team << [@user, :developer] diff --git a/spec/features/commits_spec.rb b/spec/features/commits_spec.rb index d8f5a2f804f..45e1a157a1f 100644 --- a/spec/features/commits_spec.rb +++ b/spec/features/commits_spec.rb @@ -8,15 +8,15 @@ describe 'Commits' do describe 'CI' do before do login_as :user - stub_ci_commit_to_return_yaml_file + stub_ci_pipeline_to_return_yaml_file end - let!(:commit) do - FactoryGirl.create :ci_commit, project: project, sha: project.commit.sha + let!(:pipeline) do + FactoryGirl.create :ci_pipeline, project: project, sha: project.commit.sha end context 'commit status is Generic Commit Status' do - let!(:status) { FactoryGirl.create :generic_commit_status, pipeline: commit } + let!(:status) { FactoryGirl.create :generic_commit_status, pipeline: pipeline } before do project.team << [@user, :reporter] @@ -24,10 +24,10 @@ describe 'Commits' do describe 'Commit builds' do before do - visit ci_status_path(commit) + visit ci_status_path(pipeline) end - it { expect(page).to have_content commit.sha[0..7] } + it { expect(page).to have_content pipeline.sha[0..7] } it 'contains generic commit status build' do page.within('.table-holder') do @@ -39,7 +39,7 @@ describe 'Commits' do end context 'commit status is Ci Build' do - let!(:build) { FactoryGirl.create :ci_build, pipeline: commit } + let!(:build) { FactoryGirl.create :ci_build, pipeline: pipeline } let(:artifacts_file) { fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif') } context 'when logged as developer' do @@ -53,7 +53,7 @@ describe 'Commits' do end it 'should show build status' do - page.within("//li[@id='commit-#{commit.short_sha}']") do + page.within("//li[@id='commit-#{pipeline.short_sha}']") do expect(page).to have_css(".ci-status-link") end end @@ -61,12 +61,12 @@ describe 'Commits' do describe 'Commit builds' do before do - visit ci_status_path(commit) + visit ci_status_path(pipeline) end - it { expect(page).to have_content commit.sha[0..7] } - it { expect(page).to have_content commit.git_commit_message } - it { expect(page).to have_content commit.git_author_name } + it { expect(page).to have_content pipeline.sha[0..7] } + it { expect(page).to have_content pipeline.git_commit_message } + it { expect(page).to have_content pipeline.git_author_name } end context 'Download artifacts' do @@ -75,7 +75,7 @@ describe 'Commits' do end it do - visit ci_status_path(commit) + visit ci_status_path(pipeline) click_on 'Download artifacts' expect(page.response_headers['Content-Type']).to eq(artifacts_file.content_type) end @@ -83,7 +83,7 @@ describe 'Commits' do describe 'Cancel all builds' do it 'cancels commit' do - visit ci_status_path(commit) + visit ci_status_path(pipeline) click_on 'Cancel running' expect(page).to have_content 'canceled' end @@ -91,7 +91,7 @@ describe 'Commits' do describe 'Cancel build' do it 'cancels build' do - visit ci_status_path(commit) + visit ci_status_path(pipeline) click_on 'Cancel' expect(page).to have_content 'canceled' end @@ -100,13 +100,13 @@ describe 'Commits' do describe '.gitlab-ci.yml not found warning' do context 'ci builds enabled' do it "does not show warning" do - visit ci_status_path(commit) + visit ci_status_path(pipeline) expect(page).not_to have_content '.gitlab-ci.yml not found in this commit' end it 'shows warning' do - stub_ci_commit_yaml_file(nil) - visit ci_status_path(commit) + stub_ci_pipeline_yaml_file(nil) + visit ci_status_path(pipeline) expect(page).to have_content '.gitlab-ci.yml not found in this commit' end end @@ -114,8 +114,8 @@ describe 'Commits' do context 'ci builds disabled' do before do stub_ci_builds_disabled - stub_ci_commit_yaml_file(nil) - visit ci_status_path(commit) + stub_ci_pipeline_yaml_file(nil) + visit ci_status_path(pipeline) end it 'does not show warning' do @@ -129,13 +129,13 @@ describe 'Commits' do before do project.team << [@user, :reporter] build.update_attributes(artifacts_file: artifacts_file) - visit ci_status_path(commit) + visit ci_status_path(pipeline) end it do - expect(page).to have_content commit.sha[0..7] - expect(page).to have_content commit.git_commit_message - expect(page).to have_content commit.git_author_name + expect(page).to have_content pipeline.sha[0..7] + expect(page).to have_content pipeline.git_commit_message + expect(page).to have_content pipeline.git_author_name expect(page).to have_link('Download artifacts') expect(page).not_to have_link('Cancel running') expect(page).not_to have_link('Retry failed') @@ -148,13 +148,13 @@ describe 'Commits' do visibility_level: Gitlab::VisibilityLevel::INTERNAL, public_builds: false) build.update_attributes(artifacts_file: artifacts_file) - visit ci_status_path(commit) + visit ci_status_path(pipeline) end it do - expect(page).to have_content commit.sha[0..7] - expect(page).to have_content commit.git_commit_message - expect(page).to have_content commit.git_author_name + expect(page).to have_content pipeline.sha[0..7] + expect(page).to have_content pipeline.git_commit_message + expect(page).to have_content pipeline.git_author_name expect(page).not_to have_link('Download artifacts') expect(page).not_to have_link('Cancel running') expect(page).not_to have_link('Retry failed') diff --git a/spec/features/merge_requests/created_from_fork_spec.rb b/spec/features/merge_requests/created_from_fork_spec.rb index edc0bdec3db..12d7e52629e 100644 --- a/spec/features/merge_requests/created_from_fork_spec.rb +++ b/spec/features/merge_requests/created_from_fork_spec.rb @@ -29,7 +29,7 @@ feature 'Merge request created from fork' do include WaitForAjax given(:pipeline) do - create(:ci_commit_with_two_jobs, project: fork_project, + create(:ci_pipeline_with_two_job, project: fork_project, sha: merge_request.last_commit.id, ref: merge_request.source_branch) end diff --git a/spec/features/merge_requests/merge_when_build_succeeds_spec.rb b/spec/features/merge_requests/merge_when_build_succeeds_spec.rb index eaa3e6b1471..843bd5acedf 100644 --- a/spec/features/merge_requests/merge_when_build_succeeds_spec.rb +++ b/spec/features/merge_requests/merge_when_build_succeeds_spec.rb @@ -12,7 +12,7 @@ feature 'Merge When Build Succeeds', feature: true, js: true do end context "Active build for Merge Request" do - let!(:ci_commit) { create(:ci_commit, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch) } + let!(:pipeline) { create(:ci_pipeline, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch) } let!(:ci_build) { create(:ci_build, pipeline: ci_commit) } before do @@ -47,8 +47,8 @@ feature 'Merge When Build Succeeds', feature: true, js: true do merge_user: user, title: "MepMep", merge_when_build_succeeds: true) end - let!(:ci_commit) { create(:ci_commit, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch) } - let!(:ci_build) { create(:ci_build, pipeline: ci_commit) } + let!(:pipeline) { create(:ci_pipeline, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch) } + let!(:ci_build) { create(:ci_build, pipeline: pipeline) } before do login_as user diff --git a/spec/features/pipelines_spec.rb b/spec/features/pipelines_spec.rb index 2026cb7cf17..98703ef3ac4 100644 --- a/spec/features/pipelines_spec.rb +++ b/spec/features/pipelines_spec.rb @@ -12,7 +12,7 @@ describe "Pipelines" do end describe 'GET /:project/pipelines' do - let!(:pipeline) { create(:ci_commit, project: project, ref: 'master', status: 'running') } + let!(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', status: 'running') } [:all, :running, :branches].each do |scope| context "displaying #{scope}" do @@ -111,7 +111,7 @@ describe "Pipelines" do end describe 'GET /:project/pipelines/:id' do - let(:pipeline) { create(:ci_commit, project: project, ref: 'master') } + let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master') } before do @success = create(:ci_build, :success, pipeline: pipeline, stage: 'build', name: 'build') @@ -165,7 +165,7 @@ describe "Pipelines" do before { fill_in('Create for', with: 'master') } context 'with gitlab-ci.yml' do - before { stub_ci_commit_to_return_yaml_file } + before { stub_ci_pipeline_to_return_yaml_file } it { expect{ click_on 'Create pipeline' }.to change{ Ci::Pipeline.count }.by(1) } end diff --git a/spec/features/projects/commit/builds_spec.rb b/spec/features/projects/commit/builds_spec.rb index 40ba0bdc115..73dd568929a 100644 --- a/spec/features/projects/commit/builds_spec.rb +++ b/spec/features/projects/commit/builds_spec.rb @@ -11,7 +11,7 @@ feature 'project commit builds' do context 'when no builds triggered yet' do background do - create(:ci_commit, project: project, + create(:ci_pipeline, project: project, sha: project.commit.sha, ref: 'master') end diff --git a/spec/features/security/project/public_access_spec.rb b/spec/features/security/project/public_access_spec.rb index 4ce367c3c6d..c5f741709ad 100644 --- a/spec/features/security/project/public_access_spec.rb +++ b/spec/features/security/project/public_access_spec.rb @@ -142,8 +142,8 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/builds/:id" do - let(:commit) { create(:ci_commit, project: project) } - let(:build) { create(:ci_build, pipeline: commit) } + let(:pipeline) { create(:ci_pipeline, project: project) } + let(:build) { create(:ci_build, pipeline: pipeline) } subject { namespace_project_build_path(project.namespace, project, build.id) } context "when allowed for public" do -- cgit v1.2.1 From 836061ddfde6652c1e240ac093c32b9d95b8cd84 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 3 Jun 2016 16:28:15 +0200 Subject: Rename remaining ci_commits in specs --- spec/features/merge_requests/merge_when_build_succeeds_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/features') diff --git a/spec/features/merge_requests/merge_when_build_succeeds_spec.rb b/spec/features/merge_requests/merge_when_build_succeeds_spec.rb index 843bd5acedf..c5e6412d7bf 100644 --- a/spec/features/merge_requests/merge_when_build_succeeds_spec.rb +++ b/spec/features/merge_requests/merge_when_build_succeeds_spec.rb @@ -13,7 +13,7 @@ feature 'Merge When Build Succeeds', feature: true, js: true do context "Active build for Merge Request" do let!(:pipeline) { create(:ci_pipeline, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch) } - let!(:ci_build) { create(:ci_build, pipeline: ci_commit) } + let!(:ci_build) { create(:ci_build, pipeline: pipeline) } before do login_as user -- cgit v1.2.1 From 1f608ac4614f57130992916931ad10f4d5fd9d50 Mon Sep 17 00:00:00 2001 From: Tomasz Maczukin Date: Sat, 4 Jun 2016 00:02:40 +0200 Subject: Remove 'unscoped' from project builds selection --- spec/features/builds_spec.rb | 168 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 136 insertions(+), 32 deletions(-) (limited to 'spec/features') diff --git a/spec/features/builds_spec.rb b/spec/features/builds_spec.rb index 7a05d30e8b5..e268d76755f 100644 --- a/spec/features/builds_spec.rb +++ b/spec/features/builds_spec.rb @@ -7,6 +7,7 @@ describe "Builds" do login_as(:user) @commit = FactoryGirl.create :ci_commit @build = FactoryGirl.create :ci_build, commit: @commit + @build2 = FactoryGirl.create :ci_build @project = @commit.project @project.team << [@user, :developer] end @@ -66,13 +67,24 @@ describe "Builds" do end describe "GET /:project/builds/:id" do - before do - visit namespace_project_build_path(@project.namespace, @project, @build) + context "Build from project" do + before do + visit namespace_project_build_path(@project.namespace, @project, @build) + end + + it { expect(page.status_code).to eq(200) } + it { expect(page).to have_content @commit.sha[0..7] } + it { expect(page).to have_content @commit.git_commit_message } + it { expect(page).to have_content @commit.git_author_name } end - it { expect(page).to have_content @commit.sha[0..7] } - it { expect(page).to have_content @commit.git_commit_message } - it { expect(page).to have_content @commit.git_author_name } + context "Build from other project" do + before do + visit namespace_project_build_path(@project.namespace, @project, @build2) + end + + it { expect(page.status_code).to eq(404) } + end context "Download artifacts" do before do @@ -103,51 +115,143 @@ describe "Builds" do end describe "POST /:project/builds/:id/cancel" do - before do - @build.run! - visit namespace_project_build_path(@project.namespace, @project, @build) - click_link "Cancel" + context "Build from project" do + before do + @build.run! + visit namespace_project_build_path(@project.namespace, @project, @build) + click_link "Cancel" + end + + it { expect(page.status_code).to eq(200) } + it { expect(page).to have_content 'canceled' } + it { expect(page).to have_content 'Retry' } end - it { expect(page).to have_content 'canceled' } - it { expect(page).to have_content 'Retry' } + context "Build from other project" do + before do + @build.run! + visit namespace_project_build_path(@project.namespace, @project, @build) + page.driver.post(cancel_namespace_project_build_path(@project.namespace, @project, @build2)) + end + + it { expect(page.status_code).to eq(404) } + end end describe "POST /:project/builds/:id/retry" do - before do - @build.run! - visit namespace_project_build_path(@project.namespace, @project, @build) - click_link "Cancel" - click_link 'Retry' + context "Build from project" do + before do + @build.run! + visit namespace_project_build_path(@project.namespace, @project, @build) + click_link 'Cancel' + click_link 'Retry' + end + + it { expect(page.status_code).to eq(200) } + it { expect(page).to have_content 'pending' } + it { expect(page).to have_content 'Cancel' } end - it { expect(page).to have_content 'pending' } - it { expect(page).to have_content 'Cancel' } + context "Build from other project" do + before do + @build.run! + visit namespace_project_build_path(@project.namespace, @project, @build) + click_link 'Cancel' + page.driver.post(retry_namespace_project_build_path(@project.namespace, @project, @build2)) + end + + it { expect(page.status_code).to eq(404) } + end end describe "GET /:project/builds/:id/download" do - before do - @build.update_attributes(artifacts_file: artifacts_file) - visit namespace_project_build_path(@project.namespace, @project, @build) - page.within('.artifacts') { click_link 'Download' } + context "Build from project" do + before do + @build.update_attributes(artifacts_file: artifacts_file) + visit namespace_project_build_path(@project.namespace, @project, @build) + page.within('.artifacts') { click_link 'Download' } + end + + it { expect(page.status_code).to eq(200) } + it { expect(page.response_headers['Content-Type']).to eq(artifacts_file.content_type) } end - it { expect(page.response_headers['Content-Type']).to eq(artifacts_file.content_type) } + context "Build from other project" do + before do + @build2.update_attributes(artifacts_file: artifacts_file) + visit download_namespace_project_build_artifacts_path(@project.namespace, @project, @build2) + end + + it { expect(page.status_code).to eq(404) } + end end describe "GET /:project/builds/:id/raw" do - before do - Capybara.current_session.driver.header('X-Sendfile-Type', 'X-Sendfile') - @build.run! - @build.trace = 'BUILD TRACE' - visit namespace_project_build_path(@project.namespace, @project, @build) + context "Build from project" do + before do + Capybara.current_session.driver.header('X-Sendfile-Type', 'X-Sendfile') + @build.run! + @build.trace = 'BUILD TRACE' + visit namespace_project_build_path(@project.namespace, @project, @build) + page.within('.build-controls') { click_link 'Raw' } + end + + it 'sends the right headers' do + expect(page.status_code).to eq(200) + expect(page.response_headers['Content-Type']).to eq('text/plain; charset=utf-8') + expect(page.response_headers['X-Sendfile']).to eq(@build.path_to_trace) + end + end + + context "Build from other project" do + before do + Capybara.current_session.driver.header('X-Sendfile-Type', 'X-Sendfile') + @build2.run! + @build2.trace = 'BUILD TRACE' + visit raw_namespace_project_build_path(@project.namespace, @project, @build2) + puts page.status_code + puts current_url + end + + it 'sends the right headers' do + expect(page.status_code).to eq(404) + end + end + end + + describe "GET /:project/builds/:id/trace.json" do + context "Build from project" do + before do + visit trace_namespace_project_build_path(@project.namespace, @project, @build, format: :json) + end + + it { expect(page.status_code).to eq(200) } + end + + context "Build from other project" do + before do + visit trace_namespace_project_build_path(@project.namespace, @project, @build2, format: :json) + end + + it { expect(page.status_code).to eq(404) } + end + end + + describe "GET /:project/builds/:id/status" do + context "Build from project" do + before do + visit status_namespace_project_build_path(@project.namespace, @project, @build) + end + + it { expect(page.status_code).to eq(200) } end - it 'sends the right headers' do - page.within('.build-controls') { click_link 'Raw' } + context "Build from other project" do + before do + visit status_namespace_project_build_path(@project.namespace, @project, @build2) + end - expect(page.response_headers['Content-Type']).to eq('text/plain; charset=utf-8') - expect(page.response_headers['X-Sendfile']).to eq(@build.path_to_trace) + it { expect(page.status_code).to eq(404) } end end end -- cgit v1.2.1 From e250e8571b27ea6abdb4db4ed5e1695485c84f34 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Tue, 26 Apr 2016 23:55:58 -0500 Subject: Bulk assignment tests --- spec/features/issues/bulk_assigment_labels_spec.rb | 109 +++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 spec/features/issues/bulk_assigment_labels_spec.rb (limited to 'spec/features') diff --git a/spec/features/issues/bulk_assigment_labels_spec.rb b/spec/features/issues/bulk_assigment_labels_spec.rb new file mode 100644 index 00000000000..417c4cf09b7 --- /dev/null +++ b/spec/features/issues/bulk_assigment_labels_spec.rb @@ -0,0 +1,109 @@ +require 'rails_helper' + +feature 'Issues > Labels bulk assignment', feature: true do + include WaitForAjax + + let(:user) { create(:user) } + let!(:project) { create(:project) } + let!(:issue1) { create(:issue, project: project, title: "Issue 1") } + let!(:issue2) { create(:issue, project: project, title: "Issue 2") } + + before do + create(:label, project: project, title: 'bug') + create(:label, project: project, title: 'feature') + end + + context 'as a allowed user', js: true do + before do + project.team << [user, :master] + login_as user + + visit namespace_project_issues_path(project.namespace, project) + end + + context 'can bulk assign a label' do + context 'to all issues' do + before do + check 'check_all_issues' + open_labels_dropdown ['bug'] + click_button 'Update issues' + end + + it do + expect(find("#issue_#{issue1.id}")).to have_content 'bug' + expect(find("#issue_#{issue2.id}")).to have_content 'bug' + end + end + + context 'to a issue' do + before do + check "selected_issue_#{issue1.id}" + open_labels_dropdown ['bug'] + click_button 'Update issues' + end + + it do + expect(find("#issue_#{issue1.id}")).to have_content 'bug' + expect(find("#issue_#{issue2.id}")).not_to have_content 'bug' + end + end + end + + context 'can bulk assign multiple labels' do + context 'to all issues' do + before do + check 'check_all_issues' + open_labels_dropdown ['bug', 'feature'] + click_button 'Update issues' + end + + it do + expect(find("#issue_#{issue1.id}")).to have_content 'bug' + expect(find("#issue_#{issue1.id}")).to have_content 'feature' + expect(find("#issue_#{issue2.id}")).to have_content 'bug' + expect(find("#issue_#{issue2.id}")).to have_content 'feature' + end + end + + context 'to a issue' do + before do + check "selected_issue_#{issue1.id}" + open_labels_dropdown ['bug', 'feature'] + click_button 'Update issues' + end + + it do + expect(find("#issue_#{issue1.id}")).to have_content 'bug' + expect(find("#issue_#{issue1.id}")).to have_content 'feature' + expect(find("#issue_#{issue2.id}")).not_to have_content 'bug' + expect(find("#issue_#{issue2.id}")).not_to have_content 'feature' + end + end + end + end + + context 'as a guest' do + before do + login_as user + + visit namespace_project_issues_path(project.namespace, project) + end + + context 'cannot bulk assign labels' do + it do + expect(page).not_to have_css '.check_all_issues' + expect(page).not_to have_css '.issue-check' + end + end + end + + def open_labels_dropdown(items = []) + page.within('.issues_bulk_update') do + click_button 'Label' + wait_for_ajax + items.map do |item| + click_link item + end + end + end +end \ No newline at end of file -- cgit v1.2.1 From 112f6a1e6d2e12e4c7f507a8fc0adb996e4a25b0 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Wed, 27 Apr 2016 11:07:09 -0500 Subject: Add empty line to end of file --- spec/features/issues/bulk_assigment_labels_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/features') diff --git a/spec/features/issues/bulk_assigment_labels_spec.rb b/spec/features/issues/bulk_assigment_labels_spec.rb index 417c4cf09b7..b99729ffd09 100644 --- a/spec/features/issues/bulk_assigment_labels_spec.rb +++ b/spec/features/issues/bulk_assigment_labels_spec.rb @@ -106,4 +106,4 @@ feature 'Issues > Labels bulk assignment', feature: true do end end end -end \ No newline at end of file +end -- cgit v1.2.1 From d84f1180d8687c694f64f76a5a91a3dae7d178bf Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Fri, 6 May 2016 15:58:21 -0500 Subject: Bulk assignment tests --- spec/features/issues/bulk_assigment_labels_spec.rb | 158 ++++++++++++++++----- 1 file changed, 120 insertions(+), 38 deletions(-) (limited to 'spec/features') diff --git a/spec/features/issues/bulk_assigment_labels_spec.rb b/spec/features/issues/bulk_assigment_labels_spec.rb index b99729ffd09..df080a4c661 100644 --- a/spec/features/issues/bulk_assigment_labels_spec.rb +++ b/spec/features/issues/bulk_assigment_labels_spec.rb @@ -3,80 +3,147 @@ require 'rails_helper' feature 'Issues > Labels bulk assignment', feature: true do include WaitForAjax - let(:user) { create(:user) } - let!(:project) { create(:project) } - let!(:issue1) { create(:issue, project: project, title: "Issue 1") } - let!(:issue2) { create(:issue, project: project, title: "Issue 2") } - - before do - create(:label, project: project, title: 'bug') - create(:label, project: project, title: 'feature') - end + let(:user) { create(:user) } + let!(:project) { create(:project) } + let!(:issue1) { create(:issue, project: project, title: "Issue 1") } + let!(:issue2) { create(:issue, project: project, title: "Issue 2") } + let!(:bug) { create(:label, project: project, title: 'bug') } + let!(:feature) { create(:label, project: project, title: 'feature') } context 'as a allowed user', js: true do before do project.team << [user, :master] - login_as user - visit namespace_project_issues_path(project.namespace, project) + login_as user end - context 'can bulk assign a label' do - context 'to all issues' do - before do - check 'check_all_issues' - open_labels_dropdown ['bug'] - click_button 'Update issues' + context 'can bulk assign' do + before do + visit namespace_project_issues_path(project.namespace, project) + end + + context 'a label' do + context 'to all issues' do + before do + check 'check_all_issues' + open_labels_dropdown ['bug'] + click_button 'Update issues' + end + + it do + expect(find("#issue_#{issue1.id}")).to have_content 'bug' + expect(find("#issue_#{issue2.id}")).to have_content 'bug' + end end - it do - expect(find("#issue_#{issue1.id}")).to have_content 'bug' - expect(find("#issue_#{issue2.id}")).to have_content 'bug' + context 'to a issue' do + before do + check "selected_issue_#{issue1.id}" + open_labels_dropdown ['bug'] + click_button 'Update issues' + end + + it do + expect(find("#issue_#{issue1.id}")).to have_content 'bug' + expect(find("#issue_#{issue2.id}")).not_to have_content 'bug' + end end end - context 'to a issue' do + context 'multiple labels' do + context 'to all issues' do + before do + check 'check_all_issues' + open_labels_dropdown ['bug', 'feature'] + click_button 'Update issues' + end + + it do + expect(find("#issue_#{issue1.id}")).to have_content 'bug' + expect(find("#issue_#{issue1.id}")).to have_content 'feature' + expect(find("#issue_#{issue2.id}")).to have_content 'bug' + expect(find("#issue_#{issue2.id}")).to have_content 'feature' + end + end + + context 'to a issue' do + before do + check "selected_issue_#{issue1.id}" + open_labels_dropdown ['bug', 'feature'] + click_button 'Update issues' + end + + it do + expect(find("#issue_#{issue1.id}")).to have_content 'bug' + expect(find("#issue_#{issue1.id}")).to have_content 'feature' + expect(find("#issue_#{issue2.id}")).not_to have_content 'bug' + expect(find("#issue_#{issue2.id}")).not_to have_content 'feature' + end + end + end + end + + context 'can bulk un-assign' do + context 'all labels to all issues' do before do - check "selected_issue_#{issue1.id}" - open_labels_dropdown ['bug'] + issue1.labels << bug + issue1.labels << feature + issue2.labels << bug + issue2.labels << feature + + visit namespace_project_issues_path(project.namespace, project) + + check 'check_all_issues' + unmark_labels_in_dropdown ['bug', 'feature'] click_button 'Update issues' end it do - expect(find("#issue_#{issue1.id}")).to have_content 'bug' + expect(find("#issue_#{issue1.id}")).not_to have_content 'bug' + expect(find("#issue_#{issue1.id}")).not_to have_content 'feature' expect(find("#issue_#{issue2.id}")).not_to have_content 'bug' + expect(find("#issue_#{issue2.id}")).not_to have_content 'feature' end end - end - context 'can bulk assign multiple labels' do - context 'to all issues' do + context 'a label to a issue' do before do - check 'check_all_issues' - open_labels_dropdown ['bug', 'feature'] + issue1.labels << bug + issue2.labels << feature + + visit namespace_project_issues_path(project.namespace, project) + + check_issue issue1 + unmark_labels_in_dropdown ['bug'] click_button 'Update issues' end it do - expect(find("#issue_#{issue1.id}")).to have_content 'bug' - expect(find("#issue_#{issue1.id}")).to have_content 'feature' - expect(find("#issue_#{issue2.id}")).to have_content 'bug' + expect(find("#issue_#{issue1.id}")).not_to have_content 'bug' expect(find("#issue_#{issue2.id}")).to have_content 'feature' end end - context 'to a issue' do + context 'a label and keep the others label' do before do - check "selected_issue_#{issue1.id}" - open_labels_dropdown ['bug', 'feature'] + issue1.labels << bug + issue1.labels << feature + issue2.labels << bug + issue2.labels << feature + + visit namespace_project_issues_path(project.namespace, project) + + check_issue issue1 + check_issue issue2 + unmark_labels_in_dropdown ['bug'] click_button 'Update issues' end it do - expect(find("#issue_#{issue1.id}")).to have_content 'bug' + expect(find("#issue_#{issue1.id}")).not_to have_content 'bug' expect(find("#issue_#{issue1.id}")).to have_content 'feature' expect(find("#issue_#{issue2.id}")).not_to have_content 'bug' - expect(find("#issue_#{issue2.id}")).not_to have_content 'feature' + expect(find("#issue_#{issue2.id}")).to have_content 'feature' end end end @@ -97,13 +164,28 @@ feature 'Issues > Labels bulk assignment', feature: true do end end - def open_labels_dropdown(items = []) + def open_labels_dropdown(items = [], unmark = false) page.within('.issues_bulk_update') do click_button 'Label' wait_for_ajax items.map do |item| click_link item end + if unmark + items.map do |item| + click_link item + end + end + end + end + + def unmark_labels_in_dropdown(items = []) + open_labels_dropdown(items, true) + end + + def check_issue(issue) + page.within('.issues-list') do + check "selected_issue_#{issue.id}" end end end -- cgit v1.2.1 From 830ccdfd3e1bb6d4b0c333fd2e7931cf65dac4b9 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Mon, 9 May 2016 15:53:33 -0500 Subject: Fix failing specs --- spec/features/issues/update_issues_spec.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'spec/features') diff --git a/spec/features/issues/update_issues_spec.rb b/spec/features/issues/update_issues_spec.rb index 466a6f7dfa7..c109de1cbdb 100644 --- a/spec/features/issues/update_issues_spec.rb +++ b/spec/features/issues/update_issues_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' feature 'Multiple issue updating from issues#index', feature: true do + include WaitForAjax + let!(:project) { create(:project) } let!(:issue) { create(:issue, project: project) } let!(:user) { create(:user)} @@ -24,9 +26,7 @@ feature 'Multiple issue updating from issues#index', feature: true do it 'should be set to open' do create_closed - visit namespace_project_issues_path(project.namespace, project) - - find('.issues-state-filters a', text: 'Closed').click + visit namespace_project_issues_path(project.namespace, project, state: 'closed') find('#check_all_issues').click find('.js-issue-status').click @@ -61,8 +61,8 @@ feature 'Multiple issue updating from issues#index', feature: true do click_link 'Unassigned' click_update_issues_button - - within first('.issue .controls') do + sleep 1 # needed + page.within first('.issue .controls') do expect(page).to have_no_selector('.author_link') end end @@ -95,7 +95,8 @@ feature 'Multiple issue updating from issues#index', feature: true do find('.dropdown-menu-milestone a', text: "No Milestone").click click_update_issues_button - expect(first('.issue')).not_to have_content milestone.title + sleep 1 # needed + expect(first('.issue')).to_not have_content milestone.title end end @@ -113,5 +114,6 @@ feature 'Multiple issue updating from issues#index', feature: true do def click_update_issues_button find('.update_selected_issues').click + wait_for_ajax end end -- cgit v1.2.1 From 15108cbaac059b341eae9d733c5ff8cb1dfbdb28 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Tue, 10 May 2016 18:11:16 -0500 Subject: Fix spec --- spec/features/issues/update_issues_spec.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'spec/features') diff --git a/spec/features/issues/update_issues_spec.rb b/spec/features/issues/update_issues_spec.rb index c109de1cbdb..c6181eed9af 100644 --- a/spec/features/issues/update_issues_spec.rb +++ b/spec/features/issues/update_issues_spec.rb @@ -42,7 +42,7 @@ feature 'Multiple issue updating from issues#index', feature: true do visit namespace_project_issues_path(project.namespace, project) find('#check_all_issues').click - find('.js-update-assignee').click + click_update_assignee_button find('.dropdown-menu-user-link', text: user.username).click click_update_issues_button @@ -57,14 +57,11 @@ feature 'Multiple issue updating from issues#index', feature: true do visit namespace_project_issues_path(project.namespace, project) find('#check_all_issues').click - find('.js-update-assignee').click + click_update_assignee_button click_link 'Unassigned' click_update_issues_button - sleep 1 # needed - page.within first('.issue .controls') do - expect(page).to have_no_selector('.author_link') - end + expect(find('.issue:first-child .controls')).not_to have_css('.author_link') end end @@ -95,8 +92,7 @@ feature 'Multiple issue updating from issues#index', feature: true do find('.dropdown-menu-milestone a', text: "No Milestone").click click_update_issues_button - sleep 1 # needed - expect(first('.issue')).to_not have_content milestone.title + expect(find('.issue:first-child')).to_not have_content milestone.title end end @@ -112,6 +108,11 @@ feature 'Multiple issue updating from issues#index', feature: true do create(:issue, project: project, milestone: milestone) end + def click_update_assignee_button + find('.js-update-assignee').click + wait_for_ajax + end + def click_update_issues_button find('.update_selected_issues').click wait_for_ajax -- cgit v1.2.1 From 5ea01651758beee85003bafd9ebea767090cb9f1 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Fri, 13 May 2016 00:56:37 -0500 Subject: Enhancements --- spec/features/issues/bulk_assigment_labels_spec.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'spec/features') diff --git a/spec/features/issues/bulk_assigment_labels_spec.rb b/spec/features/issues/bulk_assigment_labels_spec.rb index df080a4c661..c58b87281a3 100644 --- a/spec/features/issues/bulk_assigment_labels_spec.rb +++ b/spec/features/issues/bulk_assigment_labels_spec.rb @@ -27,7 +27,7 @@ feature 'Issues > Labels bulk assignment', feature: true do before do check 'check_all_issues' open_labels_dropdown ['bug'] - click_button 'Update issues' + update_issues end it do @@ -40,7 +40,7 @@ feature 'Issues > Labels bulk assignment', feature: true do before do check "selected_issue_#{issue1.id}" open_labels_dropdown ['bug'] - click_button 'Update issues' + update_issues end it do @@ -55,7 +55,7 @@ feature 'Issues > Labels bulk assignment', feature: true do before do check 'check_all_issues' open_labels_dropdown ['bug', 'feature'] - click_button 'Update issues' + update_issues end it do @@ -70,7 +70,7 @@ feature 'Issues > Labels bulk assignment', feature: true do before do check "selected_issue_#{issue1.id}" open_labels_dropdown ['bug', 'feature'] - click_button 'Update issues' + update_issues end it do @@ -95,7 +95,7 @@ feature 'Issues > Labels bulk assignment', feature: true do check 'check_all_issues' unmark_labels_in_dropdown ['bug', 'feature'] - click_button 'Update issues' + update_issues end it do @@ -115,7 +115,7 @@ feature 'Issues > Labels bulk assignment', feature: true do check_issue issue1 unmark_labels_in_dropdown ['bug'] - click_button 'Update issues' + update_issues end it do @@ -136,7 +136,7 @@ feature 'Issues > Labels bulk assignment', feature: true do check_issue issue1 check_issue issue2 unmark_labels_in_dropdown ['bug'] - click_button 'Update issues' + update_issues end it do @@ -188,4 +188,9 @@ feature 'Issues > Labels bulk assignment', feature: true do check "selected_issue_#{issue.id}" end end + + def update_issues + click_button 'Update issues' + wait_for_ajax + end end -- cgit v1.2.1 From d78fd6df0c21f56887d1ca76cb5a40c16d3552b0 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Mon, 23 May 2016 12:02:53 -0500 Subject: Update CHANGELOG --- spec/features/issues/update_issues_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/features') diff --git a/spec/features/issues/update_issues_spec.rb b/spec/features/issues/update_issues_spec.rb index c6181eed9af..ddbd69b2891 100644 --- a/spec/features/issues/update_issues_spec.rb +++ b/spec/features/issues/update_issues_spec.rb @@ -92,7 +92,7 @@ feature 'Multiple issue updating from issues#index', feature: true do find('.dropdown-menu-milestone a', text: "No Milestone").click click_update_issues_button - expect(find('.issue:first-child')).to_not have_content milestone.title + expect(find('.issue:first-child')).not_to have_content milestone.title end end -- cgit v1.2.1 From 515a5aeb3325848de22eec6421b1a0dcaf434e2c Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 1 Jun 2016 10:11:30 +0100 Subject: Fixed JS errors CHANGELOG item --- spec/features/issues_spec.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'spec/features') diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index a4eed5031c9..460d7f82b36 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -365,13 +365,9 @@ describe 'Issues', feature: true do page.within('.assignee') do expect(page).to have_content "#{@user.name}" - end - find('.block.assignee .edit-link').click - sleep 2 # wait for ajax stuff to complete - first('.dropdown-menu-user-link').click - sleep 2 - page.within('.assignee') do + click_link 'Edit' + click_link 'Unassigned' expect(page).to have_content 'No assignee' end -- cgit v1.2.1 From 791cc9138be6ea1783e3c3853370cf0290f4d41e Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Mon, 6 Jun 2016 10:08:42 +0530 Subject: Add a `U2fRegistrations` table/model. - To hold registrations from U2F devices, and to authenticate them. - Previously, `User#two_factor_enabled` was aliased to the `otp_required_for_login` column on `users`. - This commit changes things a bit: - `User#two_factor_enabled` is not a method anymore - `User#two_factor_enabled?` checks both the `otp_required_for_login` column, as well as `U2fRegistration`s - Change all instances of `User#two_factor_enabled` to `User#two_factor_enabled?` - Add the `u2f` gem, and implement registration/authentication at the model level. --- spec/features/admin/admin_users_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'spec/features') diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb index 96621843b30..b72ad405479 100644 --- a/spec/features/admin/admin_users_spec.rb +++ b/spec/features/admin/admin_users_spec.rb @@ -19,7 +19,7 @@ describe "Admin::Users", feature: true do describe 'Two-factor Authentication filters' do it 'counts users who have enabled 2FA' do - create(:user, two_factor_enabled: true) + create(:user, :two_factor) visit admin_users_path @@ -29,7 +29,7 @@ describe "Admin::Users", feature: true do end it 'filters by users who have enabled 2FA' do - user = create(:user, two_factor_enabled: true) + user = create(:user, :two_factor) visit admin_users_path click_link '2FA Enabled' @@ -38,7 +38,7 @@ describe "Admin::Users", feature: true do end it 'counts users who have not enabled 2FA' do - create(:user, two_factor_enabled: false) + create(:user) visit admin_users_path @@ -48,7 +48,7 @@ describe "Admin::Users", feature: true do end it 'filters by users who have not enabled 2FA' do - user = create(:user, two_factor_enabled: false) + user = create(:user) visit admin_users_path click_link '2FA Disabled' @@ -173,7 +173,7 @@ describe "Admin::Users", feature: true do describe 'Two-factor Authentication status' do it 'shows when enabled' do - @user.update_attribute(:two_factor_enabled, true) + @user.update_attribute(:otp_required_for_login, true) visit admin_user_path(@user) -- cgit v1.2.1 From 86b07caa599a7f064e9077770b1a87c670d7607c Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Mon, 6 Jun 2016 10:20:39 +0530 Subject: Implement authentication (login) using a U2F device. - Move the `authenticate_with_two_factor` method from `ApplicationController` to the `AuthenticatesWithTwoFactor` module, where it should be. --- spec/features/login_spec.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'spec/features') diff --git a/spec/features/login_spec.rb b/spec/features/login_spec.rb index c1b178c3b6c..72b5ff231f7 100644 --- a/spec/features/login_spec.rb +++ b/spec/features/login_spec.rb @@ -33,11 +33,11 @@ feature 'Login', feature: true do before do login_with(user, remember: true) - expect(page).to have_content('Two-factor Authentication') + expect(page).to have_content('Two-Factor Authentication') end def enter_code(code) - fill_in 'Two-factor Authentication code', with: code + fill_in 'Two-Factor Authentication code', with: code click_button 'Verify code' end @@ -143,12 +143,12 @@ feature 'Login', feature: true do context 'within the grace period' do it 'redirects to two-factor configuration page' do - expect(current_path).to eq new_profile_two_factor_auth_path - expect(page).to have_content('You must enable Two-factor Authentication for your account before') + expect(current_path).to eq profile_two_factor_auth_path + expect(page).to have_content('You must enable Two-Factor Authentication for your account before') end - it 'disallows skipping two-factor configuration' do - expect(current_path).to eq new_profile_two_factor_auth_path + it 'allows skipping two-factor configuration', js: true do + expect(current_path).to eq profile_two_factor_auth_path click_link 'Configure it later' expect(current_path).to eq root_path @@ -159,26 +159,26 @@ feature 'Login', feature: true do let(:user) { create(:user, otp_grace_period_started_at: 9999.hours.ago) } it 'redirects to two-factor configuration page' do - expect(current_path).to eq new_profile_two_factor_auth_path - expect(page).to have_content('You must enable Two-factor Authentication for your account.') + expect(current_path).to eq profile_two_factor_auth_path + expect(page).to have_content('You must enable Two-Factor Authentication for your account.') end - it 'disallows skipping two-factor configuration' do - expect(current_path).to eq new_profile_two_factor_auth_path + it 'disallows skipping two-factor configuration', js: true do + expect(current_path).to eq profile_two_factor_auth_path expect(page).not_to have_link('Configure it later') end end end - context 'without grace pariod defined' do + context 'without grace period defined' do before(:each) do stub_application_setting(two_factor_grace_period: 0) login_with(user) end it 'redirects to two-factor configuration page' do - expect(current_path).to eq new_profile_two_factor_auth_path - expect(page).to have_content('You must enable Two-factor Authentication for your account.') + expect(current_path).to eq profile_two_factor_auth_path + expect(page).to have_content('You must enable Two-Factor Authentication for your account.') end end end -- cgit v1.2.1 From 7232bdb9ad459147201d4ec5250465776168a62b Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Mon, 6 Jun 2016 10:23:27 +0530 Subject: Add feature specs covering U2F registration and authentication. --- spec/features/u2f_spec.rb | 239 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100644 spec/features/u2f_spec.rb (limited to 'spec/features') diff --git a/spec/features/u2f_spec.rb b/spec/features/u2f_spec.rb new file mode 100644 index 00000000000..366a90228b1 --- /dev/null +++ b/spec/features/u2f_spec.rb @@ -0,0 +1,239 @@ +require 'spec_helper' + +feature 'Using U2F (Universal 2nd Factor) Devices for Authentication', feature: true, js: true do + def register_u2f_device(u2f_device = nil) + u2f_device ||= FakeU2fDevice.new(page) + u2f_device.respond_to_u2f_registration + click_on 'Setup New U2F Device' + expect(page).to have_content('Your device was successfully set up') + click_on 'Register U2F Device' + u2f_device + end + + describe "registration" do + let(:user) { create(:user) } + before { login_as(user) } + + describe 'when 2FA via OTP is disabled' do + it 'allows registering a new device' do + visit profile_account_path + click_on 'Enable Two-Factor Authentication' + + register_u2f_device + + expect(page.body).to match('Your U2F device was registered') + end + + it 'allows registering more than one device' do + visit profile_account_path + + # First device + click_on 'Enable Two-Factor Authentication' + register_u2f_device + expect(page.body).to match('Your U2F device was registered') + + # Second device + click_on 'Manage Two-Factor Authentication' + register_u2f_device + expect(page.body).to match('Your U2F device was registered') + click_on 'Manage Two-Factor Authentication' + + expect(page.body).to match('You have 2 U2F devices registered') + end + end + + describe 'when 2FA via OTP is enabled' do + before { user.update_attributes(otp_required_for_login: true) } + + it 'allows registering a new device' do + visit profile_account_path + click_on 'Manage Two-Factor Authentication' + expect(page.body).to match("You've already enabled two-factor authentication using mobile") + + register_u2f_device + + expect(page.body).to match('Your U2F device was registered') + end + + it 'allows registering more than one device' do + visit profile_account_path + + # First device + click_on 'Manage Two-Factor Authentication' + register_u2f_device + expect(page.body).to match('Your U2F device was registered') + + # Second device + click_on 'Manage Two-Factor Authentication' + register_u2f_device + expect(page.body).to match('Your U2F device was registered') + + click_on 'Manage Two-Factor Authentication' + expect(page.body).to match('You have 2 U2F devices registered') + end + end + + it 'allows the same device to be registered for multiple users' do + # First user + visit profile_account_path + click_on 'Enable Two-Factor Authentication' + u2f_device = register_u2f_device + expect(page.body).to match('Your U2F device was registered') + logout + + # Second user + login_as(:user) + visit profile_account_path + click_on 'Enable Two-Factor Authentication' + register_u2f_device(u2f_device) + expect(page.body).to match('Your U2F device was registered') + + expect(U2fRegistration.count).to eq(2) + end + + context "when there are form errors" do + it "doesn't register the device if there are errors" do + visit profile_account_path + click_on 'Enable Two-Factor Authentication' + + # Have the "u2f device" respond with bad data + page.execute_script("u2f.register = function(_,_,_,callback) { callback('bad response'); };") + click_on 'Setup New U2F Device' + expect(page).to have_content('Your device was successfully set up') + click_on 'Register U2F Device' + + expect(U2fRegistration.count).to eq(0) + expect(page.body).to match("The form contains the following error") + expect(page.body).to match("did not send a valid JSON response") + end + + it "allows retrying registration" do + visit profile_account_path + click_on 'Enable Two-Factor Authentication' + + # Failed registration + page.execute_script("u2f.register = function(_,_,_,callback) { callback('bad response'); };") + click_on 'Setup New U2F Device' + expect(page).to have_content('Your device was successfully set up') + click_on 'Register U2F Device' + expect(page.body).to match("The form contains the following error") + + # Successful registration + register_u2f_device + + expect(page.body).to match('Your U2F device was registered') + expect(U2fRegistration.count).to eq(1) + end + end + end + + describe "authentication" do + let(:user) { create(:user) } + + before do + # Register and logout + login_as(user) + visit profile_account_path + click_on 'Enable Two-Factor Authentication' + @u2f_device = register_u2f_device + logout + end + + describe "when 2FA via OTP is disabled" do + it "allows logging in with the U2F device" do + login_with(user) + + @u2f_device.respond_to_u2f_authentication + click_on "Login Via U2F Device" + expect(page.body).to match('We heard back from your U2F device') + click_on "Authenticate via U2F Device" + + expect(page.body).to match('Signed in successfully') + end + end + + describe "when 2FA via OTP is enabled" do + it "allows logging in with the U2F device" do + user.update_attributes(otp_required_for_login: true) + login_with(user) + + @u2f_device.respond_to_u2f_authentication + click_on "Login Via U2F Device" + expect(page.body).to match('We heard back from your U2F device') + click_on "Authenticate via U2F Device" + + expect(page.body).to match('Signed in successfully') + end + end + + describe "when a given U2F device has already been registered by another user" do + describe "but not the current user" do + it "does not allow logging in with that particular device" do + # Register current user with the different U2F device + current_user = login_as(:user) + visit profile_account_path + click_on 'Enable Two-Factor Authentication' + register_u2f_device + logout + + # Try authenticating user with the old U2F device + login_as(current_user) + @u2f_device.respond_to_u2f_authentication + click_on "Login Via U2F Device" + expect(page.body).to match('We heard back from your U2F device') + click_on "Authenticate via U2F Device" + + expect(page.body).to match('Authentication via U2F device failed') + end + end + + describe "and also the current user" do + it "allows logging in with that particular device" do + # Register current user with the same U2F device + current_user = login_as(:user) + visit profile_account_path + click_on 'Enable Two-Factor Authentication' + register_u2f_device(@u2f_device) + logout + + # Try authenticating user with the same U2F device + login_as(current_user) + @u2f_device.respond_to_u2f_authentication + click_on "Login Via U2F Device" + expect(page.body).to match('We heard back from your U2F device') + click_on "Authenticate via U2F Device" + + expect(page.body).to match('Signed in successfully') + end + end + end + + describe "when a given U2F device has not been registered" do + it "does not allow logging in with that particular device" do + unregistered_device = FakeU2fDevice.new(page) + login_as(user) + unregistered_device.respond_to_u2f_authentication + click_on "Login Via U2F Device" + expect(page.body).to match('We heard back from your U2F device') + click_on "Authenticate via U2F Device" + + expect(page.body).to match('Authentication via U2F device failed') + end + end + end + + describe "when two-factor authentication is disabled" do + let(:user) { create(:user) } + + before do + login_as(user) + visit profile_account_path + click_on 'Enable Two-Factor Authentication' + register_u2f_device + end + + it "deletes u2f registrations" do + expect { click_on "Disable" }.to change { U2fRegistration.count }.from(1).to(0) + end + end +end -- cgit v1.2.1 From 0960cba0902776a5c41f55f3729260db4562236f Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Thu, 19 May 2016 16:21:26 -0500 Subject: Add tests for label prioritization --- .../projects/labels/update_prioritization_spec.rb | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 spec/features/projects/labels/update_prioritization_spec.rb (limited to 'spec/features') diff --git a/spec/features/projects/labels/update_prioritization_spec.rb b/spec/features/projects/labels/update_prioritization_spec.rb new file mode 100644 index 00000000000..2fcaed84169 --- /dev/null +++ b/spec/features/projects/labels/update_prioritization_spec.rb @@ -0,0 +1,78 @@ +require 'spec_helper' + +feature 'Prioritize labels', feature: true do + include WaitForAjax + + let(:user) { create(:user) } + let(:project) { create(:project, name: 'test', namespace: user.namespace) } + + scenario 'user can prioritize a label', js: true do + bug = create(:label, title: 'bug') + wontfix = create(:label, title: 'wontfix') + + project.labels << bug + project.labels << wontfix + + login_as user + visit namespace_project_labels_path(project.namespace, project) + + expect(page).to have_content('No prioritized labels yet') + + page.within('.other-labels') do + first('.js-toggle-priority').click + wait_for_ajax + expect(page).not_to have_content('bug') + end + + page.within('.prioritized-labels') do + expect(page).not_to have_content('No prioritized labels yet') + expect(page).to have_content('bug') + end + end + + scenario 'user can unprioritize a label', js: true do + bug = create(:label, title: 'bug', priority: 1) + wontfix = create(:label, title: 'wontfix') + + project.labels << bug + project.labels << wontfix + + login_as user + visit namespace_project_labels_path(project.namespace, project) + + expect(page).to have_content('bug') + + page.within('.prioritized-labels') do + first('.js-toggle-priority').click + wait_for_ajax + expect(page).not_to have_content('bug') + end + + page.within('.other-labels') do + expect(page).to have_content('bug') + expect(page).to have_content('wontfix') + end + end + + scenario 'user can sort prioritized labels', js: true do + bug = create(:label, title: 'bug', priority: 1) + wontfix = create(:label, title: 'wontfix', priority: 2) + + project.labels << bug + project.labels << wontfix + + login_as user + visit namespace_project_labels_path(project.namespace, project) + + expect(page).to have_content 'bug' + expect(page).to have_content 'wontfix' + + # Sort labels + find("#label_#{bug.id}").drag_to find("#label_#{wontfix.id}") + + page.within('.prioritized-labels') do + expect(first('li')).to have_content('wontfix') + expect(page.all('li').last).to have_content('bug') + end + end +end -- cgit v1.2.1 From 91e6bc1258c5e9923482b7829ed38191a2f572d7 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Thu, 19 May 2016 19:52:40 -0500 Subject: Add tests for issue prioritization --- .../labels/issues_sorted_by_priority_spec.rb | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 spec/features/projects/labels/issues_sorted_by_priority_spec.rb (limited to 'spec/features') diff --git a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb new file mode 100644 index 00000000000..097ee4350fc --- /dev/null +++ b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb @@ -0,0 +1,63 @@ +require 'spec_helper' + +feature 'Issue prioritization', feature: true do + + let(:user) { create(:user) } + let(:project) { create(:project, name: 'test', namespace: user.namespace) } + + # According to https://gitlab.com/gitlab-org/gitlab-ce/issues/14189#note_4360653 + context 'when assigned with prioritized labels' do + scenario 'Are sorted properly' do + login_as user + + label_1 = create(:label, title: 'label_1', priority: 1) + label_2 = create(:label, title: 'label_2', priority: 2) + label_3 = create(:label, title: 'label_3', priority: 3) + label_4 = create(:label, title: 'label_4', priority: 4) + label_5 = create(:label, title: 'label_5') # no priority + + project.labels << label_1 + project.labels << label_2 + project.labels << label_3 + project.labels << label_4 + project.labels << label_5 + + issue_1 = create(:issue, title: 'issue_1', project: project) + issue_2 = create(:issue, title: 'issue_2', project: project) + issue_3 = create(:issue, title: 'issue_3', project: project) + issue_4 = create(:issue, title: 'issue_4', project: project) + issue_5 = create(:issue, title: 'issue_5', project: project) + issue_6 = create(:issue, title: 'issue_6', project: project) + issue_7 = create(:issue, title: 'issue_7', project: project) + issue_8 = create(:issue, title: 'issue_8', project: project) + + # Assign labels to issues disorderly + issue_4.labels << label_1 + issue_3.labels << label_2 + issue_5.labels << label_3 + issue_2.labels << label_4 + issue_1.labels << label_5 + issue_6.labels << label_5 + issue_7.labels << label_5 + issue_8.labels << label_5 + + visit namespace_project_issues_path(project.namespace, project, sort: 'priority') + + # Ensure we are indicating that issues are sorted by priority + expect(page).to have_selector('.dropdown-toggle', text: 'Priority') + + page.within('.issues-list') do + expect(find('> li:nth-of-type(1)')).to have_content('issue_4') + expect(find('> li:nth-of-type(2)')).to have_content('issue_3') + expect(find('> li:nth-of-type(3)')).to have_content('issue_5') + expect(find('> li:nth-of-type(4)')).to have_content('issue_2') + + # the rest should be at the bottom + expect(find('> li:nth-of-type(5)')).to have_content('issue_7') + expect(find('> li:nth-of-type(6)')).to have_content('issue_8') + expect(find('> li:nth-of-type(7)')).to have_content('issue_1') + expect(find('> li:nth-of-type(8)')).to have_content('issue_6') + end + end + end +end -- cgit v1.2.1 From 6aea7666c336ba1dffa192249b391164d4b50d36 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Fri, 20 May 2016 19:01:01 -0500 Subject: Add tests for issues with multiple labels --- .../labels/issues_sorted_by_priority_spec.rb | 89 +++++++++++++++------- 1 file changed, 60 insertions(+), 29 deletions(-) (limited to 'spec/features') diff --git a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb index 097ee4350fc..fac70087c0b 100644 --- a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb +++ b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb @@ -5,31 +5,23 @@ feature 'Issue prioritization', feature: true do let(:user) { create(:user) } let(:project) { create(:project, name: 'test', namespace: user.namespace) } + # Labels + let(:label_1) { create(:label, title: 'label_1', project: project, priority: 1) } + let(:label_2) { create(:label, title: 'label_2', project: project, priority: 2) } + let(:label_3) { create(:label, title: 'label_3', project: project, priority: 3) } + let(:label_4) { create(:label, title: 'label_4', project: project, priority: 4) } + let(:label_5) { create(:label, title: 'label_5', project: project) } # no priority + # According to https://gitlab.com/gitlab-org/gitlab-ce/issues/14189#note_4360653 - context 'when assigned with prioritized labels' do + context 'when issues have one label' do scenario 'Are sorted properly' do - login_as user - - label_1 = create(:label, title: 'label_1', priority: 1) - label_2 = create(:label, title: 'label_2', priority: 2) - label_3 = create(:label, title: 'label_3', priority: 3) - label_4 = create(:label, title: 'label_4', priority: 4) - label_5 = create(:label, title: 'label_5') # no priority - - project.labels << label_1 - project.labels << label_2 - project.labels << label_3 - project.labels << label_4 - project.labels << label_5 + # Issues issue_1 = create(:issue, title: 'issue_1', project: project) issue_2 = create(:issue, title: 'issue_2', project: project) issue_3 = create(:issue, title: 'issue_3', project: project) issue_4 = create(:issue, title: 'issue_4', project: project) issue_5 = create(:issue, title: 'issue_5', project: project) - issue_6 = create(:issue, title: 'issue_6', project: project) - issue_7 = create(:issue, title: 'issue_7', project: project) - issue_8 = create(:issue, title: 'issue_8', project: project) # Assign labels to issues disorderly issue_4.labels << label_1 @@ -37,26 +29,65 @@ feature 'Issue prioritization', feature: true do issue_5.labels << label_3 issue_2.labels << label_4 issue_1.labels << label_5 - issue_6.labels << label_5 - issue_7.labels << label_5 - issue_8.labels << label_5 + login_as user visit namespace_project_issues_path(project.namespace, project, sort: 'priority') # Ensure we are indicating that issues are sorted by priority expect(page).to have_selector('.dropdown-toggle', text: 'Priority') - page.within('.issues-list') do - expect(find('> li:nth-of-type(1)')).to have_content('issue_4') - expect(find('> li:nth-of-type(2)')).to have_content('issue_3') - expect(find('> li:nth-of-type(3)')).to have_content('issue_5') - expect(find('> li:nth-of-type(4)')).to have_content('issue_2') + page.within('.issues-holder') do + expect(page).to have_selector('.issues-list > li:nth-of-type(1)', text: 'issue_4') + expect(page).to have_selector('.issues-list > li:nth-of-type(2)', text: 'issue_3') + expect(page).to have_selector('.issues-list > li:nth-of-type(3)', text: 'issue_5') + expect(page).to have_selector('.issues-list > li:nth-of-type(4)', text: 'issue_2') # the rest should be at the bottom - expect(find('> li:nth-of-type(5)')).to have_content('issue_7') - expect(find('> li:nth-of-type(6)')).to have_content('issue_8') - expect(find('> li:nth-of-type(7)')).to have_content('issue_1') - expect(find('> li:nth-of-type(8)')).to have_content('issue_6') + expect(page).to have_selector('.issues-list > li:nth-of-type(5)', text: 'issue_1') + end + end + end + + context 'when issues have multiple labels' do + scenario 'Are sorted properly' do + + # Issues + issue_1 = create(:issue, title: 'issue_1', project: project) + issue_2 = create(:issue, title: 'issue_2', project: project) + issue_3 = create(:issue, title: 'issue_3', project: project) + issue_4 = create(:issue, title: 'issue_4', project: project) + issue_5 = create(:issue, title: 'issue_5', project: project) + issue_6 = create(:issue, title: 'issue_6', project: project) + issue_7 = create(:issue, title: 'issue_7', project: project) + issue_8 = create(:issue, title: 'issue_8', project: project) + + # Assign labels to issues disorderly + issue_5.labels << label_1 # 1 + issue_5.labels << label_2 + issue_8.labels << label_1 # 2 + issue_1.labels << label_2 # 3 + issue_1.labels << label_3 + issue_3.labels << label_2 # 4 + issue_3.labels << label_4 + issue_7.labels << label_2 # 5 + issue_2.labels << label_3 # 6 + issue_4.labels << label_4 # 7 + issue_6.labels << label_5 # 8 – No priority + + login_as user + visit namespace_project_issues_path(project.namespace, project, sort: 'priority') + + expect(page).to have_selector('.dropdown-toggle', text: 'Priority') + + page.within('.issues-holder') do + expect(page).to have_selector('.issues-list > li:nth-of-type(1)', text: 'issue_5') + expect(page).to have_selector('.issues-list > li:nth-of-type(2)', text: 'issue_8') + expect(page).to have_selector('.issues-list > li:nth-of-type(3)', text: 'issue_1') + expect(page).to have_selector('.issues-list > li:nth-of-type(4)', text: 'issue_3') + expect(page).to have_selector('.issues-list > li:nth-of-type(5)', text: 'issue_7') + expect(page).to have_selector('.issues-list > li:nth-of-type(6)', text: 'issue_2') + expect(page).to have_selector('.issues-list > li:nth-of-type(7)', text: 'issue_4') + expect(page).to have_selector('.issues-list > li:nth-of-type(8)', text: 'issue_6') end end end -- cgit v1.2.1 From 1cc0209a8057c32cb7b073b822410f8b4c4ad3c9 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Wed, 1 Jun 2016 13:35:43 +0100 Subject: Fix style - `reorder(nil)` is better than `reorder('')` - Only use ASCII in comments --- spec/features/projects/labels/issues_sorted_by_priority_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'spec/features') diff --git a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb index fac70087c0b..453ded8ee71 100644 --- a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb +++ b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb @@ -1,3 +1,4 @@ +# coding: utf-8 require 'spec_helper' feature 'Issue prioritization', feature: true do @@ -72,7 +73,7 @@ feature 'Issue prioritization', feature: true do issue_7.labels << label_2 # 5 issue_2.labels << label_3 # 6 issue_4.labels << label_4 # 7 - issue_6.labels << label_5 # 8 – No priority + issue_6.labels << label_5 # 8 - No priority login_as user visit namespace_project_issues_path(project.namespace, project, sort: 'priority') -- cgit v1.2.1 From 2ca32a09b68b1b74e8142d6211ffc8f70acf472e Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Fri, 3 Jun 2016 02:14:39 -0500 Subject: Add test for the case when user can't prioritize labels --- .../projects/labels/update_prioritization_spec.rb | 124 +++++++++++++-------- 1 file changed, 77 insertions(+), 47 deletions(-) (limited to 'spec/features') diff --git a/spec/features/projects/labels/update_prioritization_spec.rb b/spec/features/projects/labels/update_prioritization_spec.rb index 2fcaed84169..2a0bf6548db 100644 --- a/spec/features/projects/labels/update_prioritization_spec.rb +++ b/spec/features/projects/labels/update_prioritization_spec.rb @@ -3,76 +3,106 @@ require 'spec_helper' feature 'Prioritize labels', feature: true do include WaitForAjax - let(:user) { create(:user) } - let(:project) { create(:project, name: 'test', namespace: user.namespace) } + context 'when project belongs to user' do + let(:user) { create(:user) } + let(:project) { create(:project, name: 'test', namespace: user.namespace) } - scenario 'user can prioritize a label', js: true do - bug = create(:label, title: 'bug') - wontfix = create(:label, title: 'wontfix') + scenario 'user can prioritize a label', js: true do + bug = create(:label, title: 'bug') + wontfix = create(:label, title: 'wontfix') - project.labels << bug - project.labels << wontfix + project.labels << bug + project.labels << wontfix - login_as user - visit namespace_project_labels_path(project.namespace, project) + login_as user + visit namespace_project_labels_path(project.namespace, project) - expect(page).to have_content('No prioritized labels yet') + expect(page).to have_content('No prioritized labels yet') - page.within('.other-labels') do - first('.js-toggle-priority').click - wait_for_ajax - expect(page).not_to have_content('bug') + page.within('.other-labels') do + first('.js-toggle-priority').click + wait_for_ajax + expect(page).not_to have_content('bug') + end + + page.within('.prioritized-labels') do + expect(page).not_to have_content('No prioritized labels yet') + expect(page).to have_content('bug') + end end - page.within('.prioritized-labels') do - expect(page).not_to have_content('No prioritized labels yet') + scenario 'user can unprioritize a label', js: true do + bug = create(:label, title: 'bug', priority: 1) + wontfix = create(:label, title: 'wontfix') + + project.labels << bug + project.labels << wontfix + + login_as user + visit namespace_project_labels_path(project.namespace, project) + expect(page).to have_content('bug') + + page.within('.prioritized-labels') do + first('.js-toggle-priority').click + wait_for_ajax + expect(page).not_to have_content('bug') + end + + page.within('.other-labels') do + expect(page).to have_content('bug') + expect(page).to have_content('wontfix') + end end - end - scenario 'user can unprioritize a label', js: true do - bug = create(:label, title: 'bug', priority: 1) - wontfix = create(:label, title: 'wontfix') + scenario 'user can sort prioritized labels', js: true do + bug = create(:label, title: 'bug', priority: 1) + wontfix = create(:label, title: 'wontfix', priority: 2) - project.labels << bug - project.labels << wontfix + project.labels << bug + project.labels << wontfix - login_as user - visit namespace_project_labels_path(project.namespace, project) + login_as user + visit namespace_project_labels_path(project.namespace, project) - expect(page).to have_content('bug') + expect(page).to have_content 'bug' + expect(page).to have_content 'wontfix' - page.within('.prioritized-labels') do - first('.js-toggle-priority').click - wait_for_ajax - expect(page).not_to have_content('bug') - end + # Sort labels + find("#label_#{bug.id}").drag_to find("#label_#{wontfix.id}") - page.within('.other-labels') do - expect(page).to have_content('bug') - expect(page).to have_content('wontfix') + page.within('.prioritized-labels') do + expect(first('li')).to have_content('wontfix') + expect(page.all('li').last).to have_content('bug') + end end end - scenario 'user can sort prioritized labels', js: true do - bug = create(:label, title: 'bug', priority: 1) - wontfix = create(:label, title: 'wontfix', priority: 2) + context 'as a guest' do + it 'can not prioritize labels' do + user = create(:user) + guest = create(:user) + project = create(:project, name: 'test', namespace: user.namespace) + + create(:label, title: 'bug') - project.labels << bug - project.labels << wontfix + login_as guest + visit namespace_project_labels_path(project.namespace, project) + + expect(page).not_to have_css('.prioritized-labels') + end + end - login_as user - visit namespace_project_labels_path(project.namespace, project) + context 'as a non signed in user' do + it 'can not prioritize labels' do + user = create(:user) + project = create(:project, name: 'test', namespace: user.namespace) - expect(page).to have_content 'bug' - expect(page).to have_content 'wontfix' + create(:label, title: 'bug') - # Sort labels - find("#label_#{bug.id}").drag_to find("#label_#{wontfix.id}") + visit namespace_project_labels_path(project.namespace, project) - page.within('.prioritized-labels') do - expect(first('li')).to have_content('wontfix') - expect(page.all('li').last).to have_content('bug') + expect(page).not_to have_css('.prioritized-labels') end end end -- cgit v1.2.1 From b0ec4b9cc37f30c90d4bceff5e8b8efbac25dedc Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Fri, 3 Jun 2016 18:06:23 -0500 Subject: Remove comment Just to trigger CI --- spec/features/projects/labels/issues_sorted_by_priority_spec.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'spec/features') diff --git a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb index 453ded8ee71..323b2665996 100644 --- a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb +++ b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 require 'spec_helper' feature 'Issue prioritization', feature: true do -- cgit v1.2.1 From 7bc65b2bef1aaacb0122eabca23e1db0849321b0 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Mon, 6 Jun 2016 16:12:32 +0100 Subject: Clarify issue priority spec We don't care particularly about the ordering within a priority level, just that the levels are in the right order. --- .../labels/issues_sorted_by_priority_spec.rb | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'spec/features') diff --git a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb index 323b2665996..461f1737928 100644 --- a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb +++ b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb @@ -37,13 +37,9 @@ feature 'Issue prioritization', feature: true do expect(page).to have_selector('.dropdown-toggle', text: 'Priority') page.within('.issues-holder') do - expect(page).to have_selector('.issues-list > li:nth-of-type(1)', text: 'issue_4') - expect(page).to have_selector('.issues-list > li:nth-of-type(2)', text: 'issue_3') - expect(page).to have_selector('.issues-list > li:nth-of-type(3)', text: 'issue_5') - expect(page).to have_selector('.issues-list > li:nth-of-type(4)', text: 'issue_2') + issue_titles = all('.issues-list .issue-title-text').map(&:text) - # the rest should be at the bottom - expect(page).to have_selector('.issues-list > li:nth-of-type(5)', text: 'issue_1') + expect(issue_titles).to eq(['issue_4', 'issue_3', 'issue_5', 'issue_2', 'issue_1']) end end end @@ -80,14 +76,11 @@ feature 'Issue prioritization', feature: true do expect(page).to have_selector('.dropdown-toggle', text: 'Priority') page.within('.issues-holder') do - expect(page).to have_selector('.issues-list > li:nth-of-type(1)', text: 'issue_5') - expect(page).to have_selector('.issues-list > li:nth-of-type(2)', text: 'issue_8') - expect(page).to have_selector('.issues-list > li:nth-of-type(3)', text: 'issue_1') - expect(page).to have_selector('.issues-list > li:nth-of-type(4)', text: 'issue_3') - expect(page).to have_selector('.issues-list > li:nth-of-type(5)', text: 'issue_7') - expect(page).to have_selector('.issues-list > li:nth-of-type(6)', text: 'issue_2') - expect(page).to have_selector('.issues-list > li:nth-of-type(7)', text: 'issue_4') - expect(page).to have_selector('.issues-list > li:nth-of-type(8)', text: 'issue_6') + issue_titles = all('.issues-list .issue-title-text').map(&:text) + + expect(issue_titles[0..1]).to contain_exactly('issue_5', 'issue_8') + expect(issue_titles[2..4]).to contain_exactly('issue_1', 'issue_3', 'issue_7') + expect(issue_titles[5..-1]).to eq(['issue_2', 'issue_4', 'issue_6']) end end end -- cgit v1.2.1 From dbf235f514cc919a10fee1d9ab8dc1c75bc25238 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 7 Jun 2016 10:25:57 +0200 Subject: Fix tests failures --- spec/features/merge_requests/created_from_fork_spec.rb | 4 ++-- spec/features/projects/commit/builds_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'spec/features') diff --git a/spec/features/merge_requests/created_from_fork_spec.rb b/spec/features/merge_requests/created_from_fork_spec.rb index 12d7e52629e..b4d2201c729 100644 --- a/spec/features/merge_requests/created_from_fork_spec.rb +++ b/spec/features/merge_requests/created_from_fork_spec.rb @@ -30,8 +30,8 @@ feature 'Merge request created from fork' do given(:pipeline) do create(:ci_pipeline_with_two_job, project: fork_project, - sha: merge_request.last_commit.id, - ref: merge_request.source_branch) + sha: merge_request.last_commit.id, + ref: merge_request.source_branch) end background { pipeline.create_builds(user) } diff --git a/spec/features/projects/commit/builds_spec.rb b/spec/features/projects/commit/builds_spec.rb index 73dd568929a..15c381c0f5a 100644 --- a/spec/features/projects/commit/builds_spec.rb +++ b/spec/features/projects/commit/builds_spec.rb @@ -12,8 +12,8 @@ feature 'project commit builds' do context 'when no builds triggered yet' do background do create(:ci_pipeline, project: project, - sha: project.commit.sha, - ref: 'master') + sha: project.commit.sha, + ref: 'master') end scenario 'user views commit builds page' do -- cgit v1.2.1 From ee26c3cab4651c8876efc45b6a63539727e6a42e Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Tue, 7 Jun 2016 11:57:09 +0100 Subject: Fix label order by priority on labels page --- spec/features/projects/labels/update_prioritization_spec.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'spec/features') diff --git a/spec/features/projects/labels/update_prioritization_spec.rb b/spec/features/projects/labels/update_prioritization_spec.rb index 2a0bf6548db..8550d279d09 100644 --- a/spec/features/projects/labels/update_prioritization_spec.rb +++ b/spec/features/projects/labels/update_prioritization_spec.rb @@ -55,7 +55,7 @@ feature 'Prioritize labels', feature: true do end end - scenario 'user can sort prioritized labels', js: true do + scenario 'user can sort prioritized labels and persist across reloads', js: true do bug = create(:label, title: 'bug', priority: 1) wontfix = create(:label, title: 'wontfix', priority: 2) @@ -75,6 +75,13 @@ feature 'Prioritize labels', feature: true do expect(first('li')).to have_content('wontfix') expect(page.all('li').last).to have_content('bug') end + + visit current_url + + page.within('.prioritized-labels') do + expect(first('li')).to have_content('wontfix') + expect(page.all('li').last).to have_content('bug') + end end end -- cgit v1.2.1 From ffbd9cd02d701442b5304e84ad75d657eeb4e23f Mon Sep 17 00:00:00 2001 From: Annabel Dunstone Date: Thu, 2 Jun 2016 17:31:26 -0600 Subject: Test impersonation using img data attribute instead of username --- spec/features/admin/admin_users_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'spec/features') diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb index b72ad405479..1cb709c1de3 100644 --- a/spec/features/admin/admin_users_spec.rb +++ b/spec/features/admin/admin_users_spec.rb @@ -144,8 +144,8 @@ describe "Admin::Users", feature: true do before { click_link 'Impersonate' } it 'logs in as the user when impersonate is clicked' do - page.within '.sidebar-user .username' do - expect(page).to have_content(another_user.username) + page.within '.sidebar-wrapper' do + expect(page.find('.sidebar-user')['data-user']).to eql(another_user.username) end end @@ -158,8 +158,8 @@ describe "Admin::Users", feature: true do it 'can log out of impersonated user back to original user' do find(:css, 'li.impersonation a').click - page.within '.sidebar-user .username' do - expect(page).to have_content(@user.username) + page.within '.sidebar-wrapper' do + expect(page.find('.sidebar-user')['data-user']).to eql(@user.username) end end -- cgit v1.2.1 From 76d618404ee8a47a34b45dfe41d268eaaf52f00d Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 7 Jun 2016 19:45:44 +0200 Subject: Fix markdown_spec to not use `before(:all)` in order to properly cleanup database after testing --- spec/features/markdown_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/features') diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb index 1d892fe1a55..7663d193354 100644 --- a/spec/features/markdown_spec.rb +++ b/spec/features/markdown_spec.rb @@ -180,7 +180,7 @@ describe 'GitLab Markdown', feature: true do end end - before(:all) do + before do @feat = MarkdownFeature.new # `markdown` helper expects a `@project` variable @@ -188,7 +188,7 @@ describe 'GitLab Markdown', feature: true do end context 'default pipeline' do - before(:all) do + before do @html = markdown(@feat.raw_markdown) end -- cgit v1.2.1 From 519c758fa9fabe9b73f784a9f5b80579b2d84325 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 17 May 2016 12:07:11 +0100 Subject: Removable labels from filtered issuables label bar When filtering by labels, a remove button appears next to each label. This then removes that label & refreshes the issuable filter form Closes #15474 --- spec/features/issues/filter_by_labels_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'spec/features') diff --git a/spec/features/issues/filter_by_labels_spec.rb b/spec/features/issues/filter_by_labels_spec.rb index 7f654684143..2015b0434fb 100644 --- a/spec/features/issues/filter_by_labels_spec.rb +++ b/spec/features/issues/filter_by_labels_spec.rb @@ -54,6 +54,11 @@ feature 'Issue filtering by Labels', feature: true do expect(find('.filtered-labels')).not_to have_content "feature" expect(find('.filtered-labels')).not_to have_content "enhancement" end + + it 'should remove label "bug"' do + first('.js-label-filter-remove').click + expect(find('.filtered-labels')).to have_no_content "bug" + end end context 'filter by label feature', js: true do @@ -135,6 +140,11 @@ feature 'Issue filtering by Labels', feature: true do it 'should not show label "bug" in filtered-labels' do expect(find('.filtered-labels')).not_to have_content "bug" end + + it 'should remove label "enhancement"' do + first('.js-label-filter-remove').click + expect(find('.filtered-labels')).to have_no_content "enhancement" + end end context 'filter by label enhancement and bug in issues list', js: true do -- cgit v1.2.1 From d3ff691d768fcb40171c11cade8a659a62534160 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Thu, 2 Jun 2016 10:40:42 +0100 Subject: Fixed issue with dropdown toggle not updating Added tests --- spec/features/issues/filter_by_labels_spec.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'spec/features') diff --git a/spec/features/issues/filter_by_labels_spec.rb b/spec/features/issues/filter_by_labels_spec.rb index 2015b0434fb..0ec8b6b180a 100644 --- a/spec/features/issues/filter_by_labels_spec.rb +++ b/spec/features/issues/filter_by_labels_spec.rb @@ -174,4 +174,29 @@ feature 'Issue filtering by Labels', feature: true do expect(find('.filtered-labels')).not_to have_content "feature" end end + + context 'remove filtered labels', js: true do + before do + page.within '.labels-filter' do + click_button 'Label' + click_link 'bug' + find('.dropdown-menu-close').click + end + + page.within '.filtered-labels' do + expect(page).to have_content 'bug' + end + end + + it 'should allow user to remove filtered labels' do + page.within '.filtered-labels' do + first('.js-label-filter-remove').click + expect(page).not_to have_content 'bug' + end + + page.within '.labels-filter' do + expect(page).not_to have_content 'bug' + end + end + end end -- cgit v1.2.1 From 7be19db42fd51da23b1ef658263897213b624500 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Wed, 8 Jun 2016 02:02:55 -0500 Subject: Set target="_blank" for external links --- spec/features/markdown_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'spec/features') diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb index 7663d193354..cabccdacf87 100644 --- a/spec/features/markdown_spec.rb +++ b/spec/features/markdown_spec.rb @@ -173,10 +173,20 @@ describe 'GitLab Markdown', feature: true do expect(link.attr('rel')).to include('noreferrer') end + it 'adds _blank to target attribute for external links' do + link = doc.at_css('a:contains("Google")') + expect(link.attr('target')).to match('_blank') + end + it 'ignores internal link' do link = doc.at_css('a:contains("GitLab Root")') expect(link.attr('rel')).not_to match 'nofollow' end + + it 'does not set _blank to target attribute for internal links' do + link = doc.at_css('a:contains("GitLab Root")') + expect(link.attr('target')).not_to match '_blank' + end end end -- cgit v1.2.1 From 27ada5aa4690affd04ada606d15a44a598184c57 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Wed, 8 Jun 2016 12:20:24 -0500 Subject: Combine tests for internal links --- spec/features/markdown_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'spec/features') diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb index cabccdacf87..1193cae5a2f 100644 --- a/spec/features/markdown_spec.rb +++ b/spec/features/markdown_spec.rb @@ -165,26 +165,26 @@ describe 'GitLab Markdown', feature: true do describe 'ExternalLinkFilter' do it 'adds nofollow to external link' do link = doc.at_css('a:contains("Google")') + expect(link.attr('rel')).to include('nofollow') end it 'adds noreferrer to external link' do link = doc.at_css('a:contains("Google")') + expect(link.attr('rel')).to include('noreferrer') end it 'adds _blank to target attribute for external links' do link = doc.at_css('a:contains("Google")') + expect(link.attr('target')).to match('_blank') end it 'ignores internal link' do link = doc.at_css('a:contains("GitLab Root")') - expect(link.attr('rel')).not_to match 'nofollow' - end - it 'does not set _blank to target attribute for internal links' do - link = doc.at_css('a:contains("GitLab Root")') + expect(link.attr('rel')).not_to match 'nofollow' expect(link.attr('target')).not_to match '_blank' end end -- cgit v1.2.1 From e6b1d1669b362ad4cea27ac44e89e73f4d6e92fd Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Wed, 8 Jun 2016 10:32:50 +0530 Subject: Hook up the updated `WikiLinkFilter` to the wiki controllers. - Need to pass in a `page_slug` to the filter, so it can rewrite based on the current page (all links are rewritten to the level of the app root). - The earlier `markdown_preview` endpoint was at the level of the wiki. We need to know the current page (for rewriting, as above), so this commit moves the endpoint to the level of a wiki page. - Fix all tests --- spec/features/markdown_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'spec/features') diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb index 1d892fe1a55..07275bfb3d8 100644 --- a/spec/features/markdown_spec.rb +++ b/spec/features/markdown_spec.rb @@ -231,13 +231,14 @@ describe 'GitLab Markdown', feature: true do context 'wiki pipeline' do before do @project_wiki = @feat.project_wiki + @project_wiki_page = @feat.project_wiki_page file = Gollum::File.new(@project_wiki.wiki) expect(file).to receive(:path).and_return('images/example.jpg') expect(@project_wiki).to receive(:find_file).with('images/example.jpg').and_return(file) allow(@project_wiki).to receive(:wiki_base_path) { '/namespace1/gitlabhq/wikis' } - @html = markdown(@feat.raw_markdown, { pipeline: :wiki, project_wiki: @project_wiki }) + @html = markdown(@feat.raw_markdown, { pipeline: :wiki, project_wiki: @project_wiki, page_slug: @project_wiki_page.slug }) end it_behaves_like 'all pipelines' -- cgit v1.2.1 From d301791c2aa101b68f9b5abda24f20dc24a85830 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Thu, 9 Jun 2016 10:44:17 +0100 Subject: Added tests --- spec/features/issues/filter_by_labels_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'spec/features') diff --git a/spec/features/issues/filter_by_labels_spec.rb b/spec/features/issues/filter_by_labels_spec.rb index 0ec8b6b180a..16c619c9288 100644 --- a/spec/features/issues/filter_by_labels_spec.rb +++ b/spec/features/issues/filter_by_labels_spec.rb @@ -199,4 +199,19 @@ feature 'Issue filtering by Labels', feature: true do end end end + + context 'dropdown filtering', js: true do + it 'should filter by label name' do + page.within '.labels-filter' do + click_button 'Label' + wait_for_ajax + fill_in 'label-name', with: 'bug' + + page.within '.dropdown-content' do + expect(page).not_to have_content 'enhancement' + expect(page).to have_content 'bug' + end + end + end + end end -- cgit v1.2.1 From 340aa444b709291958f2ab3a21352d9e182705d8 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Wed, 25 May 2016 14:32:37 -0500 Subject: Add tests for dates on tooltips --- .../dashboard/datetime_on_tooltips_spec.rb | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 spec/features/dashboard/datetime_on_tooltips_spec.rb (limited to 'spec/features') diff --git a/spec/features/dashboard/datetime_on_tooltips_spec.rb b/spec/features/dashboard/datetime_on_tooltips_spec.rb new file mode 100644 index 00000000000..e77db0dd2a2 --- /dev/null +++ b/spec/features/dashboard/datetime_on_tooltips_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper' + +feature 'Tooltips on .timeago dates', feature: true, js: true do + include WaitForAjax + + let(:user) { create(:user) } + let(:project) { create(:project, name: 'test', namespace: user.namespace) } + let(:created_date) { Date.yesterday.to_time } + let(:expected_format) { created_date.strftime('%b %d, %Y %l:%M%P UTC') } + + context 'on the activity tab' do + before do + project.team << [user, :master] + + Event.create( project: project, author_id: user.id, action: Event::JOINED, + updated_at: created_date, created_at: created_date) + + login_as user + visit user_path(user) + wait_for_ajax() + + page.find('.js-timeago').hover + end + + it 'has the datetime formated correctly' do + expect(page).to have_selector('.local-timeago', text: expected_format) + end + end + + context 'on the snippets tab' do + before do + project.team << [user, :master] + create(:snippet, author: user, updated_at: created_date, created_at: created_date) + + login_as user + visit user_snippets_path(user) + wait_for_ajax() + + page.find('.js-timeago').hover + end + + it 'has the datetime formated correctly' do + expect(page).to have_selector('.local-timeago', text: expected_format) + end + end +end -- cgit v1.2.1 From 541e663c125f322cdbb680a9081f2e8470d9ef4e Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Thu, 9 Jun 2016 14:35:11 -0500 Subject: Change date format to be non zero padded in order to fix failing test --- spec/features/dashboard/datetime_on_tooltips_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/features') diff --git a/spec/features/dashboard/datetime_on_tooltips_spec.rb b/spec/features/dashboard/datetime_on_tooltips_spec.rb index e77db0dd2a2..365cb445df1 100644 --- a/spec/features/dashboard/datetime_on_tooltips_spec.rb +++ b/spec/features/dashboard/datetime_on_tooltips_spec.rb @@ -6,7 +6,7 @@ feature 'Tooltips on .timeago dates', feature: true, js: true do let(:user) { create(:user) } let(:project) { create(:project, name: 'test', namespace: user.namespace) } let(:created_date) { Date.yesterday.to_time } - let(:expected_format) { created_date.strftime('%b %d, %Y %l:%M%P UTC') } + let(:expected_format) { created_date.strftime('%b %-d, %Y %l:%M%P UTC') } context 'on the activity tab' do before do -- cgit v1.2.1 From 7c88141b958c372b8a787c1d724bd8e5bd66f024 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 6 Jun 2016 11:11:57 +0100 Subject: Fixed tests --- spec/features/issues_spec.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'spec/features') diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index 460d7f82b36..f6fb6a72d22 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -75,12 +75,13 @@ describe 'Issues', feature: true do fill_in 'issue_title', with: 'bug 345' fill_in 'issue_description', with: 'bug description' + find('#issuable-due-date').click - page.within '.datepicker' do + page.within '.ui-datepicker' do click_link date.day end - expect(find('#issuable-due-date', visible: false).value).to eq date.to_s + expect(find('#issuable-due-date').value).to eq date.to_s click_button 'Submit issue' @@ -100,18 +101,19 @@ describe 'Issues', feature: true do it 'should save with due date' do date = Date.today.at_beginning_of_month - expect(find('#issuable-due-date', visible: false).value).to eq date.to_s + expect(find('#issuable-due-date').value).to eq date.to_s date = date.tomorrow fill_in 'issue_title', with: 'bug 345' fill_in 'issue_description', with: 'bug description' + find('#issuable-due-date').click - page.within '.datepicker' do + page.within '.ui-datepicker' do click_link date.day end - expect(find('#issuable-due-date', visible: false).value).to eq date.to_s + expect(find('#issuable-due-date').value).to eq date.to_s click_button 'Save changes' -- cgit v1.2.1 From a4b3bdabd52494f46fee73271d7b343e6b7e08e9 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 10 Jun 2016 08:52:08 +0100 Subject: removed tests needed for any author :poop: --- spec/features/issues/filter_issues_spec.rb | 36 ------------------------------ 1 file changed, 36 deletions(-) (limited to 'spec/features') diff --git a/spec/features/issues/filter_issues_spec.rb b/spec/features/issues/filter_issues_spec.rb index 7efbaaa048c..1f0594e6b02 100644 --- a/spec/features/issues/filter_issues_spec.rb +++ b/spec/features/issues/filter_issues_spec.rb @@ -294,40 +294,4 @@ describe 'Filter issues', feature: true do end end end - - describe 'filter by any author', js: true do - before do - user2 = create(:user, name: "tester") - create(:issue, project: project, author: user) - create(:issue, project: project, author: user2) - - visit namespace_project_issues_path(project.namespace, project) - end - - it 'should show filter by any author link' do - click_button "Author" - fill_in "Search authors", with: "tester" - - page.within ".dropdown-menu-author" do - expect(page).to have_content "tester" - end - end - - it 'should show filter issues by any author' do - page.within '.issues-list' do - expect(page).to have_selector ".issue", count: 2 - end - - click_button "Author" - fill_in "Search authors", with: "tester" - - page.within ".dropdown-menu-author" do - click_link "tester" - end - - page.within '.issues-list' do - expect(page).to have_selector ".issue", count: 1 - end - end - end end -- cgit v1.2.1 From dc6ec2adf82c2b2fe1ab6ef076432fd741d3afbb Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 20 Apr 2016 10:11:22 +0100 Subject: CI build page UI update Added sidebar Removed elements not present in design --- spec/features/builds_spec.rb | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'spec/features') diff --git a/spec/features/builds_spec.rb b/spec/features/builds_spec.rb index df221ab1f3b..cb94432dbd0 100644 --- a/spec/features/builds_spec.rb +++ b/spec/features/builds_spec.rb @@ -93,9 +93,7 @@ describe "Builds" do end it 'has button to download artifacts' do - page.within('.artifacts') do - expect(page).to have_content 'Download' - end + expect(page).to have_content 'Download' end end @@ -107,9 +105,7 @@ describe "Builds" do end it do - page.within('.build-controls') do - expect(page).to have_link 'Raw' - end + expect(page).to have_link 'Raw' end end end @@ -165,15 +161,10 @@ describe "Builds" do end describe "GET /:project/builds/:id/download" do - context "Build from project" do - before do - @build.update_attributes(artifacts_file: artifacts_file) - visit namespace_project_build_path(@project.namespace, @project, @build) - page.within('.artifacts') { click_link 'Download' } - end - - it { expect(page.status_code).to eq(200) } - it { expect(page.response_headers['Content-Type']).to eq(artifacts_file.content_type) } + before do + @build.update_attributes(artifacts_file: artifacts_file) + visit namespace_project_build_path(@project.namespace, @project, @build) + click_link 'Download' end context "Build from other project" do @@ -246,10 +237,8 @@ describe "Builds" do it { expect(page.status_code).to eq(200) } end - context "Build from other project" do - before do - visit status_namespace_project_build_path(@project.namespace, @project, @build2) - end + it 'sends the right headers' do + click_link 'Raw' it { expect(page.status_code).to eq(404) } end -- cgit v1.2.1 From a6345c14011e9ffa8cca45f9058a1529c7be5b62 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 7 Jun 2016 12:02:37 +0100 Subject: Fixed failing tests --- spec/features/builds_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'spec/features') diff --git a/spec/features/builds_spec.rb b/spec/features/builds_spec.rb index cb94432dbd0..0c865e915cb 100644 --- a/spec/features/builds_spec.rb +++ b/spec/features/builds_spec.rb @@ -237,8 +237,10 @@ describe "Builds" do it { expect(page.status_code).to eq(200) } end - it 'sends the right headers' do - click_link 'Raw' + context "Build from other project" do + before do + visit status_namespace_project_build_path(@project.namespace, @project, @build2) + end it { expect(page.status_code).to eq(404) } end -- cgit v1.2.1 From 07dbd6b3884c4f188b2c3f29dd7419791f1051eb Mon Sep 17 00:00:00 2001 From: Rui Anderson Date: Wed, 27 Apr 2016 15:34:42 -0300 Subject: Allow or not merge MR with failed build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- .../only_allow_merge_if_build_succeeds.rb | 105 +++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 spec/features/merge_requests/only_allow_merge_if_build_succeeds.rb (limited to 'spec/features') diff --git a/spec/features/merge_requests/only_allow_merge_if_build_succeeds.rb b/spec/features/merge_requests/only_allow_merge_if_build_succeeds.rb new file mode 100644 index 00000000000..1627aa7287a --- /dev/null +++ b/spec/features/merge_requests/only_allow_merge_if_build_succeeds.rb @@ -0,0 +1,105 @@ +require 'spec_helper' + +feature 'Only allow merge requests to be merged if the build succeeds', feature: true, js: true do + let(:user) { create(:user) } + + let(:project) { create(:project, :public) } + let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user) } + + before do + login_as user + + project.team << [user, :master] + end + + context "project hasn't ci enabled" do + it "allows MR to be merged" do + visit_merge_request(merge_request) + expect(page).to have_button "Accept Merge Request" + end + end + + context "when project has ci enabled" do + let!(:ci_commit) { create(:ci_commit, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch) } + let!(:ci_build) { create(:ci_build, commit: ci_commit) } + + before do + project.enable_ci + end + + context "when merge requests can only be merged if the build succeeds" do + before do + project.update_attribute(:only_allow_merge_if_build_succeeds, true) + end + + context "when ci is running" do + it "doesn't allow to merge immediately" do + ci_commit.statuses.update_all(status: :pending) + visit_merge_request(merge_request) + + expect(page).to have_button "Merge When Build Succeeds" + expect(page).to_not have_button "Select Merge Moment" + end + end + + context "when ci failed" do + it "doesn't allow MR to be merged" do + ci_commit.statuses.update_all(status: :failed) + visit_merge_request(merge_request) + + expect(page).to_not have_button "Accept Merge Request" + expect(page).to have_content("Please retry the build or push code to fix the failure.") + end + end + + context "when ci succeed" do + it "allows MR to be merged" do + ci_commit.statuses.update_all(status: :success) + visit_merge_request(merge_request) + + expect(page).to have_button "Accept Merge Request" + end + end + end + + context "when merge requests can be merged when the build failed" do + before do + project.update_attribute(:only_allow_merge_if_build_succeeds, false) + end + + context "when ci is running" do + it "allows MR to be merged immediately" do + ci_commit.statuses.update_all(status: :pending) + visit_merge_request(merge_request) + + expect(page).to have_button "Merge When Build Succeeds" + + click_button "Select Merge Moment" + expect(page).to have_content "Merge Immediately" + end + end + + context "when ci failed" do + it "allows MR to be merged" do + ci_commit.statuses.update_all(status: :failed) + visit_merge_request(merge_request) + + expect(page).to have_button "Accept Merge Request" + end + end + + context "when ci succeed" do + it "allows MR to be merged" do + ci_commit.statuses.update_all(status: :success) + visit_merge_request(merge_request) + + expect(page).to have_button "Accept Merge Request" + end + end + end + end + + def visit_merge_request(merge_request) + visit namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request) + end +end -- cgit v1.2.1 From 6dff7c1771e0cfeb6906244649b3683090bc2929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Tue, 7 Jun 2016 13:01:34 +0200 Subject: Improve initial implementation of the 'only_allow_merge_if_build_succeeds.rb' feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on the feedback from reviewers. Signed-off-by: Rémy Coutable --- .../only_allow_merge_if_build_succeeds.rb | 92 +++++++++++----------- 1 file changed, 46 insertions(+), 46 deletions(-) (limited to 'spec/features') diff --git a/spec/features/merge_requests/only_allow_merge_if_build_succeeds.rb b/spec/features/merge_requests/only_allow_merge_if_build_succeeds.rb index 1627aa7287a..52612c91824 100644 --- a/spec/features/merge_requests/only_allow_merge_if_build_succeeds.rb +++ b/spec/features/merge_requests/only_allow_merge_if_build_succeeds.rb @@ -1,99 +1,99 @@ require 'spec_helper' -feature 'Only allow merge requests to be merged if the build succeeds', feature: true, js: true do - let(:user) { create(:user) } - +feature 'Only allow merge requests to be merged if the build succeeds', feature: true do let(:project) { create(:project, :public) } - let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user) } + let(:merge_request) { create(:merge_request_with_diffs, source_project: project) } before do - login_as user + login_as merge_request.author - project.team << [user, :master] + project.team << [merge_request.author, :master] end - context "project hasn't ci enabled" do - it "allows MR to be merged" do + context 'project does not have CI enabled' do + it 'allows MR to be merged' do visit_merge_request(merge_request) - expect(page).to have_button "Accept Merge Request" + + expect(page).to have_button 'Accept Merge Request' end end - context "when project has ci enabled" do - let!(:ci_commit) { create(:ci_commit, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch) } - let!(:ci_build) { create(:ci_build, commit: ci_commit) } + context 'when project has CI enabled' do + let(:ci_commit) { create(:ci_empty_pipeline, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch) } - before do - project.enable_ci - end - - context "when merge requests can only be merged if the build succeeds" do + context 'when merge requests can only be merged if the build succeeds' do before do project.update_attribute(:only_allow_merge_if_build_succeeds, true) end - context "when ci is running" do - it "doesn't allow to merge immediately" do - ci_commit.statuses.update_all(status: :pending) + context 'when CI is running' do + before { ci_commit.update_column(:status, :running) } + + it 'does not allow to merge immediately' do visit_merge_request(merge_request) - expect(page).to have_button "Merge When Build Succeeds" - expect(page).to_not have_button "Select Merge Moment" + expect(page).to have_button 'Merge When Build Succeeds' + expect(page).not_to have_button 'Select Merge Moment' end end - context "when ci failed" do - it "doesn't allow MR to be merged" do - ci_commit.statuses.update_all(status: :failed) + context 'when CI failed' do + before { ci_commit.update_column(:status, :failed) } + + it 'does not allow MR to be merged' do visit_merge_request(merge_request) - expect(page).to_not have_button "Accept Merge Request" - expect(page).to have_content("Please retry the build or push code to fix the failure.") + expect(page).not_to have_button 'Accept Merge Request' + expect(page).to have_content('Please retry the build or push a new commit to fix the failure.') end end - context "when ci succeed" do - it "allows MR to be merged" do - ci_commit.statuses.update_all(status: :success) + context 'when CI succeeded' do + before { ci_commit.update_column(:status, :success) } + + it 'allows MR to be merged' do visit_merge_request(merge_request) - expect(page).to have_button "Accept Merge Request" + expect(page).to have_button 'Accept Merge Request' end end end - context "when merge requests can be merged when the build failed" do + context 'when merge requests can be merged when the build failed' do before do project.update_attribute(:only_allow_merge_if_build_succeeds, false) end - context "when ci is running" do - it "allows MR to be merged immediately" do - ci_commit.statuses.update_all(status: :pending) + context 'when CI is running' do + before { ci_commit.update_column(:status, :running) } + + it 'allows MR to be merged immediately', js: true do visit_merge_request(merge_request) - expect(page).to have_button "Merge When Build Succeeds" + expect(page).to have_button 'Merge When Build Succeeds' - click_button "Select Merge Moment" - expect(page).to have_content "Merge Immediately" + click_button 'Select Merge Moment' + expect(page).to have_content 'Merge Immediately' end end - context "when ci failed" do - it "allows MR to be merged" do - ci_commit.statuses.update_all(status: :failed) + context 'when CI failed' do + before { ci_commit.update_column(:status, :failed) } + + it 'allows MR to be merged' do visit_merge_request(merge_request) - expect(page).to have_button "Accept Merge Request" + expect(page).to have_button 'Accept Merge Request' end end - context "when ci succeed" do - it "allows MR to be merged" do - ci_commit.statuses.update_all(status: :success) + context 'when CI succeeded' do + before { ci_commit.update_column(:status, :success) } + + it 'allows MR to be merged' do visit_merge_request(merge_request) - expect(page).to have_button "Accept Merge Request" + expect(page).to have_button 'Accept Merge Request' end end end -- cgit v1.2.1 From 3579edba1f0d27095502775c64bdd73a3927dca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Fri, 10 Jun 2016 14:41:38 +0200 Subject: Rename ci_commit -> pipeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- .../merge_requests/only_allow_merge_if_build_succeeds.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'spec/features') diff --git a/spec/features/merge_requests/only_allow_merge_if_build_succeeds.rb b/spec/features/merge_requests/only_allow_merge_if_build_succeeds.rb index 52612c91824..65e9185ec24 100644 --- a/spec/features/merge_requests/only_allow_merge_if_build_succeeds.rb +++ b/spec/features/merge_requests/only_allow_merge_if_build_succeeds.rb @@ -19,7 +19,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature: end context 'when project has CI enabled' do - let(:ci_commit) { create(:ci_empty_pipeline, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch) } + let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch) } context 'when merge requests can only be merged if the build succeeds' do before do @@ -27,7 +27,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature: end context 'when CI is running' do - before { ci_commit.update_column(:status, :running) } + before { pipeline.update_column(:status, :running) } it 'does not allow to merge immediately' do visit_merge_request(merge_request) @@ -38,7 +38,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature: end context 'when CI failed' do - before { ci_commit.update_column(:status, :failed) } + before { pipeline.update_column(:status, :failed) } it 'does not allow MR to be merged' do visit_merge_request(merge_request) @@ -49,7 +49,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature: end context 'when CI succeeded' do - before { ci_commit.update_column(:status, :success) } + before { pipeline.update_column(:status, :success) } it 'allows MR to be merged' do visit_merge_request(merge_request) @@ -65,7 +65,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature: end context 'when CI is running' do - before { ci_commit.update_column(:status, :running) } + before { pipeline.update_column(:status, :running) } it 'allows MR to be merged immediately', js: true do visit_merge_request(merge_request) @@ -78,7 +78,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature: end context 'when CI failed' do - before { ci_commit.update_column(:status, :failed) } + before { pipeline.update_column(:status, :failed) } it 'allows MR to be merged' do visit_merge_request(merge_request) @@ -88,7 +88,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature: end context 'when CI succeeded' do - before { ci_commit.update_column(:status, :success) } + before { pipeline.update_column(:status, :success) } it 'allows MR to be merged' do visit_merge_request(merge_request) -- cgit v1.2.1 From 998c688699db68a6dd1fb5e6459b1a787deabcef Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 10 Jun 2016 12:07:37 +0100 Subject: Updated tests --- spec/features/builds_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/features') diff --git a/spec/features/builds_spec.rb b/spec/features/builds_spec.rb index 0c865e915cb..b8ecc356b4d 100644 --- a/spec/features/builds_spec.rb +++ b/spec/features/builds_spec.rb @@ -184,7 +184,7 @@ describe "Builds" do @build.run! @build.trace = 'BUILD TRACE' visit namespace_project_build_path(@project.namespace, @project, @build) - page.within('.build-controls') { click_link 'Raw' } + page.within('.js-build-sidebar') { click_link 'Raw' } end it 'sends the right headers' do -- cgit v1.2.1