Commit 2f66969e authored by Grzegorz Bizon's avatar Grzegorz Bizon

Improve merge when builds succeeds specs readability

parent a98e4081
...@@ -2,18 +2,26 @@ require 'spec_helper' ...@@ -2,18 +2,26 @@ require 'spec_helper'
feature 'Merge When Build Succeeds', feature: true, js: true do feature 'Merge When Build Succeeds', feature: true, js: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :public) } let(:project) { create(:project, :public) }
let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user, title: "Bug NS-04") }
before do let(:merge_request) do
project.team << [user, :master] create(:merge_request_with_diffs, source_project: project,
project.enable_ci author: user,
title: 'Bug NS-04')
end
let(:pipeline) do
create(:ci_pipeline, project: project,
sha: merge_request.diff_head_sha,
ref: merge_request.source_branch)
end end
context "Active build for Merge Request" do before { project.team << [user, :master] }
let!(:pipeline) { create(:ci_pipeline, project: project, sha: merge_request.diff_head_sha, ref: merge_request.source_branch) }
let!(:ci_build) { create(:ci_build, pipeline: pipeline) } context 'when there is active build for merge request' do
background do
create(:ci_build, pipeline: pipeline)
end
before do before do
login_as user login_as user
...@@ -41,21 +49,25 @@ feature 'Merge When Build Succeeds', feature: true, js: true do ...@@ -41,21 +49,25 @@ feature 'Merge When Build Succeeds', feature: true, js: true do
end end
end end
context 'When it is enabled' do context 'when merge when build succeeds is enabled' do
let(:merge_request) do let(:merge_request) do
create(:merge_request_with_diffs, :simple, source_project: project, author: user, create(:merge_request_with_diffs, :simple, source_project: project,
merge_user: user, title: "MepMep", merge_when_build_succeeds: true) author: user,
merge_user: user,
title: 'MepMep',
merge_when_build_succeeds: true)
end end
let!(:pipeline) { create(:ci_pipeline, project: project, sha: merge_request.diff_head_sha, ref: merge_request.source_branch) } background do
let!(:ci_build) { create(:ci_build, pipeline: pipeline) } create(:ci_build, pipeline: pipeline)
end
before do before do
login_as user login_as user
visit_merge_request(merge_request) visit_merge_request(merge_request)
end end
it 'cancels the automatic merge' do it 'allows to cancel the automatic merge' do
click_link "Cancel Automatic Merge" click_link "Cancel Automatic Merge"
expect(page).to have_button "Merge When Build Succeeds" expect(page).to have_button "Merge When Build Succeeds"
...@@ -72,8 +84,8 @@ feature 'Merge When Build Succeeds', feature: true, js: true do ...@@ -72,8 +84,8 @@ feature 'Merge When Build Succeeds', feature: true, js: true do
end end
end end
context 'Build is not active' do context 'when build is not active' do
it "does not allow for enabling" do it "does not allow to enable merge when build succeeds" do
visit_merge_request(merge_request) visit_merge_request(merge_request)
expect(page).not_to have_link "Merge When Build Succeeds" expect(page).not_to have_link "Merge When Build Succeeds"
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