diff options
7 files changed, 87 insertions, 133 deletions
diff --git a/changelogs/unreleased/blackst0ne-replace-spinach-project-ff-merge-requests-feature.yml b/changelogs/unreleased/blackst0ne-replace-spinach-project-ff-merge-requests-feature.yml new file mode 100644 index 00000000000..7802391ec64 --- /dev/null +++ b/changelogs/unreleased/blackst0ne-replace-spinach-project-ff-merge-requests-feature.yml @@ -0,0 +1,5 @@ +--- +title: 'Replace the `project/ff_merge_requests.feature` spinach test with an rspec analog' +merge_request: 18800 +author: '@blackst0ne' +type: other diff --git a/features/project/ff_merge_requests.feature b/features/project/ff_merge_requests.feature deleted file mode 100644 index 39035d551d1..00000000000 --- a/features/project/ff_merge_requests.feature +++ /dev/null @@ -1,41 +0,0 @@ -Feature: Project Ff Merge Requests - Background: - Given I sign in as a user - And I own project "Shop" - And project "Shop" have "Bug NS-05" open merge request with diffs inside - And merge request "Bug NS-05" is mergeable - - @javascript - Scenario: I do ff-only merge for rebased branch - Given ff merge enabled - And merge request "Bug NS-05" is rebased - When I visit merge request page "Bug NS-05" - Then I should see ff-only merge button - When I accept this merge request - Then I should see merged request - - @javascript - Scenario: I do ff-only merge for merged branch - Given ff merge enabled - And merge request "Bug NS-05" merged target - When I visit merge request page "Bug NS-05" - Then I should see ff-only merge button - When I accept this merge request - Then I should see merged request - - @javascript - Scenario: I do rebase before ff-only merge - Given ff merge enabled - And rebase before merge enabled - When I visit merge request page "Bug NS-05" - Then I should see rebase button - When I press rebase button - Then I should see rebase in progress message - - @javascript - Scenario: I do rebase before regular merge - Given rebase before merge enabled - When I visit merge request page "Bug NS-05" - Then I should see rebase button - When I press rebase button - Then I should see rebase in progress message diff --git a/features/steps/project/ff_merge_requests.rb b/features/steps/project/ff_merge_requests.rb deleted file mode 100644 index 27efcfd65b6..00000000000 --- a/features/steps/project/ff_merge_requests.rb +++ /dev/null @@ -1,87 +0,0 @@ -class Spinach::Features::ProjectFfMergeRequests < Spinach::FeatureSteps - include SharedAuthentication - include SharedIssuable - include SharedProject - include SharedNote - include SharedPaths - include SharedMarkdown - include SharedDiffNote - include SharedUser - include WaitForRequests - - step 'project "Shop" have "Bug NS-05" open merge request with diffs inside' do - create(:merge_request_with_diffs, - title: "Bug NS-05", - source_project: project, - target_project: project, - author: project.users.first) - end - - step 'merge request is mergeable' do - expect(page).to have_button 'Merge' - end - - step 'I should see ff-only merge button' do - expect(page).to have_content "Fast-forward merge without a merge commit" - expect(page).to have_button 'Merge' - end - - step 'merge request "Bug NS-05" is mergeable' do - merge_request.mark_as_mergeable - end - - step 'I accept this merge request' do - page.within '.mr-state-widget' do - click_button "Merge" - end - end - - step 'I should see merged request' do - page.within '.status-box' do - expect(page).to have_content "Merged" - wait_for_requests - end - end - - step 'ff merge enabled' do - project = merge_request.target_project - project.merge_requests_ff_only_enabled = true - project.save! - end - - step 'I should see rebase button' do - expect(page).to have_button "Rebase" - end - - step 'merge request "Bug NS-05" is rebased' do - merge_request.source_branch = 'flatten-dir' - merge_request.target_branch = 'improve/awesome' - merge_request.reload_diff - merge_request.save! - end - - step 'merge request "Bug NS-05" merged target' do - merge_request.source_branch = 'merged-target' - merge_request.target_branch = 'improve/awesome' - merge_request.reload_diff - merge_request.save! - end - - step 'rebase before merge enabled' do - project = merge_request.target_project - project.merge_requests_rebase_enabled = true - project.save! - end - - step 'I press rebase button' do - click_button "Rebase" - end - - step "I should see rebase in progress message" do - expect(page).to have_content("Rebase in progress") - end - - def merge_request - @merge_request ||= MergeRequest.find_by!(title: "Bug NS-05") - end -end diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index b6c648a707d..f2769f28fed 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -336,11 +336,6 @@ module SharedPaths wait_for_requests end - step 'I visit merge request page "Bug NS-05"' do - visit merge_request_path("Bug NS-05") - wait_for_requests - end - step 'I visit merge request page "Bug NS-07"' do visit merge_request_path("Bug NS-07") wait_for_requests diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb index d26cb0c3417..fab0ec22450 100644 --- a/spec/factories/merge_requests.rb +++ b/spec/factories/merge_requests.rb @@ -41,6 +41,11 @@ FactoryBot.define do state :merged end + trait :merged_target do + source_branch "merged-target" + target_branch "improve/awesome" + end + trait :closed do state :closed end diff --git a/spec/features/projects/merge_requests/user_merges_merge_request_spec.rb b/spec/features/projects/merge_requests/user_merges_merge_request_spec.rb new file mode 100644 index 00000000000..6539e6e9208 --- /dev/null +++ b/spec/features/projects/merge_requests/user_merges_merge_request_spec.rb @@ -0,0 +1,43 @@ +require "spec_helper" + +describe "User merges a merge request", :js do + let(:user) { project.owner } + + before do + sign_in(user) + end + + shared_examples "fast forward merge a merge request" do + it "merges a merge request" do + expect(page).to have_content("Fast-forward merge without a merge commit").and have_button("Merge") + + page.within(".mr-state-widget") do + click_button("Merge") + end + + page.within(".status-box") do + expect(page).to have_content("Merged") + end + end + end + + context "ff-only merge" do + let(:project) { create(:project, :public, :repository, merge_requests_ff_only_enabled: true) } + + before do + visit(merge_request_path(merge_request)) + end + + context "when branch is rebased" do + let!(:merge_request) { create(:merge_request, :rebased, source_project: project) } + + it_behaves_like "fast forward merge a merge request" + end + + context "when branch is merged" do + let!(:merge_request) { create(:merge_request, :merged_target, source_project: project) } + + it_behaves_like "fast forward merge a merge request" + end + end +end diff --git a/spec/features/projects/merge_requests/user_rebases_merge_request_spec.rb b/spec/features/projects/merge_requests/user_rebases_merge_request_spec.rb new file mode 100644 index 00000000000..92e1c9942b1 --- /dev/null +++ b/spec/features/projects/merge_requests/user_rebases_merge_request_spec.rb @@ -0,0 +1,34 @@ +require "spec_helper" + +describe "User rebases a merge request", :js do + let(:merge_request) { create(:merge_request, :simple, source_project: project) } + let(:user) { project.owner } + + before do + sign_in(user) + end + + shared_examples "rebases" do + it "rebases" do + visit(merge_request_path(merge_request)) + + expect(page).to have_button("Rebase") + + click_button("Rebase") + + expect(page).to have_content("Rebase in progress") + end + end + + context "when merge is regular" do + let(:project) { create(:project, :public, :repository, merge_requests_rebase_enabled: true) } + + it_behaves_like "rebases" + end + + context "when merge is ff-only" do + let(:project) { create(:project, :public, :repository, merge_requests_ff_only_enabled: true) } + + it_behaves_like "rebases" + end +end |