diff --git a/changelogs/unreleased/replace_project_merge_requests_accept-feature.yml b/changelogs/unreleased/replace_project_merge_requests_accept-feature.yml new file mode 100644 index 00000000000..03562d6025e --- /dev/null +++ b/changelogs/unreleased/replace_project_merge_requests_accept-feature.yml @@ -0,0 +1,5 @@ +--- +title: Replace the 'project/merge_requests/accept.feature' spinach test with an rspec analog +merge_request: 14176 +author: Vitaliy @blackst0ne Klachkov +type: other diff --git a/features/project/merge_requests/accept.feature b/features/project/merge_requests/accept.feature deleted file mode 100644 index 2ab1c19f452..00000000000 --- a/features/project/merge_requests/accept.feature +++ /dev/null @@ -1,28 +0,0 @@ -@project_merge_requests -Feature: Project Merge Requests Acceptance - Background: - Given There is an open Merge Request - And I am signed in as a developer of the project - - @javascript - Scenario: Accepting the Merge Request and removing the source branch - Given I am on the Merge Request detail page - When I check the "Remove source branch" option - And I click on Accept Merge Request - Then I should see merge request merged - And I should not see the Remove Source Branch button - - @javascript - Scenario: Accepting the Merge Request when URL has an anchor - Given I am on the Merge Request detail with note anchor page - When I check the "Remove source branch" option - And I click on Accept Merge Request - Then I should see merge request merged - And I should not see the Remove Source Branch button - - @javascript - Scenario: Accepting the Merge Request without removing the source branch - Given I am on the Merge Request detail page - When I click on Accept Merge Request - Then I should see merge request merged - And I should see the Remove Source Branch button diff --git a/features/steps/project/merge_requests/acceptance.rb b/features/steps/project/merge_requests/acceptance.rb deleted file mode 100644 index 3c640e3512a..00000000000 --- a/features/steps/project/merge_requests/acceptance.rb +++ /dev/null @@ -1,55 +0,0 @@ -class Spinach::Features::ProjectMergeRequestsAcceptance < Spinach::FeatureSteps - include LoginHelpers - include WaitForRequests - - step 'I am on the Merge Request detail page' do - visit merge_request_path(@merge_request) - end - - step 'I am on the Merge Request detail with note anchor page' do - visit merge_request_path(@merge_request, anchor: 'note_123') - end - - step 'I uncheck the "Remove source branch" option' do - uncheck('Remove source branch') - end - - step 'I check the "Remove source branch" option' do - check('Remove source branch') - end - - step 'I click on Accept Merge Request' do - click_button('Merge') - end - - step 'I should see the Remove Source Branch button' do - expect(page).to have_selector('.js-remove-branch-button') - - # Wait for View Resource requests to complete so they don't blow up if they are - # only handled after `DatabaseCleaner` has already run - wait_for_requests - end - - step 'I should not see the Remove Source Branch button' do - expect(page).not_to have_selector('.js-remove-branch-button') - - # Wait for View Resource requests to complete so they don't blow up if they are - # only handled after `DatabaseCleaner` has already run - wait_for_requests - end - - step 'There is an open Merge Request' do - @user = create(:user) - @project = create(:project, :public, :repository) - @project_member = create(:project_member, :developer, user: @user, project: @project) - @merge_request = create(:merge_request, :with_diffs, :simple, source_project: @project) - end - - step 'I am signed in as a developer of the project' do - sign_in(@user) - end - - step 'I should see merge request merged' do - expect(page).to have_content('The changes were merged into') - end -end diff --git a/spec/features/projects/merge_requests/user_accepts_merge_request_spec.rb b/spec/features/projects/merge_requests/user_accepts_merge_request_spec.rb new file mode 100644 index 00000000000..6c0b5e279d5 --- /dev/null +++ b/spec/features/projects/merge_requests/user_accepts_merge_request_spec.rb @@ -0,0 +1,65 @@ +require 'spec_helper' + +describe 'User accepts a merge request', :js do + let(:merge_request) { create(:merge_request, :with_diffs, :simple, source_project: project) } + let(:project) { create(:project, :public, :repository) } + let(:user) { create(:user) } + + before do + project.add_developer(user) + sign_in(user) + end + + context 'with removing the source branch' do + before do + visit(merge_request_path(merge_request)) + end + + it 'accepts a merge request' do + check('Remove source branch') + click_button('Merge') + + expect(page).to have_content('The changes were merged into') + expect(page).not_to have_selector('.js-remove-branch-button') + + # Wait for View Resource requests to complete so they don't blow up if they are + # only handled after `DatabaseCleaner` has already run. + wait_for_requests + end + end + + context 'without removing the source branch' do + before do + visit(merge_request_path(merge_request)) + end + + it 'accepts a merge request' do + click_button('Merge') + + expect(page).to have_content('The changes were merged into') + expect(page).to have_selector('.js-remove-branch-button') + + # Wait for View Resource requests to complete so they don't blow up if they are + # only handled after `DatabaseCleaner` has already run + wait_for_requests + end + end + + context 'when a URL has an anchor' do + before do + visit(merge_request_path(merge_request, anchor: 'note_123')) + end + + it 'accepts a merge request' do + check('Remove source branch') + click_button('Merge') + + expect(page).to have_content('The changes were merged into') + expect(page).not_to have_selector('.js-remove-branch-button') + + # Wait for View Resource requests to complete so they don't blow up if they are + # only handled after `DatabaseCleaner` has already run + wait_for_requests + end + end +end