Commit 79fdee35 authored by Alexandru Croitor's avatar Alexandru Croitor

Extract merge quick action to a shared example

parent 12522d22
...@@ -56,6 +56,8 @@ describe 'Merge request > User uses quick actions', :js do ...@@ -56,6 +56,8 @@ describe 'Merge request > User uses quick actions', :js do
project.add_maintainer(user) project.add_maintainer(user)
end end
it_behaves_like 'merge quick action'
describe 'toggling the WIP prefix in the title from note' do describe 'toggling the WIP prefix in the title from note' do
context 'when the current user can toggle the WIP prefix' do context 'when the current user can toggle the WIP prefix' do
before do before do
...@@ -103,74 +105,6 @@ describe 'Merge request > User uses quick actions', :js do ...@@ -103,74 +105,6 @@ describe 'Merge request > User uses quick actions', :js do
end end
end end
describe 'merging the MR from the note' do
context 'when the current user can merge the MR' do
before do
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
it 'merges the MR' do
add_note("/merge")
expect(page).to have_content 'Commands applied'
expect(merge_request.reload).to be_merged
end
end
context 'when the head diff changes in the meanwhile' do
before do
merge_request.source_branch = 'another_branch'
merge_request.save
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
it 'does not merge the MR' do
add_note("/merge")
expect(page).not_to have_content 'Your commands have been executed!'
expect(merge_request.reload).not_to be_merged
end
end
context 'when the current user cannot merge the MR' do
before do
project.add_guest(guest)
sign_in(guest)
visit project_merge_request_path(project, merge_request)
end
it 'does not merge the MR' do
add_note("/merge")
expect(page).not_to have_content 'Your commands have been executed!'
expect(merge_request.reload).not_to be_merged
end
end
end
describe 'adding a due date from note' do
before do
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
it_behaves_like 'due quick action not available'
end
describe 'removing a due date from note' do
before do
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
it_behaves_like 'remove_due_date action not available'
end
describe '/target_branch command in merge request' do describe '/target_branch command in merge request' do
let(:another_project) { create(:project, :public, :repository) } let(:another_project) { create(:project, :public, :repository) }
let(:new_url_opts) { { merge_request: { source_branch: 'feature' } } } let(:new_url_opts) { { merge_request: { source_branch: 'feature' } } }
......
# frozen_string_literal: true # frozen_string_literal: true
shared_examples 'merge quick action' do shared_examples 'merge quick action' do
context 'when the current user can merge the MR' do
before do
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
it 'merges the MR' do
add_note("/merge")
expect(page).to have_content 'Commands applied'
expect(merge_request.reload).to be_merged
end
end
context 'when the head diff changes in the meanwhile' do
before do
merge_request.source_branch = 'another_branch'
merge_request.save
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
it 'does not merge the MR' do
add_note("/merge")
expect(page).not_to have_content 'Your commands have been executed!'
expect(merge_request.reload).not_to be_merged
end
end
context 'when the current user cannot merge the MR' do
before do
project.add_guest(guest)
sign_in(guest)
visit project_merge_request_path(project, merge_request)
end
it 'does not merge the MR' do
add_note("/merge")
expect(page).not_to have_content 'Your commands have been executed!'
expect(merge_request.reload).not_to be_merged
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment