Commit 3cb98379 authored by blackst0ne's avatar blackst0ne Committed by Robert Speicher

Replace the `project/ff_merge_requests.feature` spinach test with an rspec analog

parent ee9d4386
---
title: 'Replace the `project/ff_merge_requests.feature` spinach test with an rspec analog'
merge_request: 18800
author: '@blackst0ne'
type: other
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
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
...@@ -336,11 +336,6 @@ module SharedPaths ...@@ -336,11 +336,6 @@ module SharedPaths
wait_for_requests wait_for_requests
end 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 step 'I visit merge request page "Bug NS-07"' do
visit merge_request_path("Bug NS-07") visit merge_request_path("Bug NS-07")
wait_for_requests wait_for_requests
......
...@@ -41,6 +41,11 @@ FactoryBot.define do ...@@ -41,6 +41,11 @@ FactoryBot.define do
state :merged state :merged
end end
trait :merged_target do
source_branch "merged-target"
target_branch "improve/awesome"
end
trait :closed do trait :closed do
state :closed state :closed
end end
......
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
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
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