Commit f25b7ac6 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '6574-extract-ee-specific-files-lines-for-spec-features-merge_request' into 'master'

Extract EE specific files/lines for spec/features/merge_request

Closes #6574

See merge request gitlab-org/gitlab-ee!10612
parents ef00dfcd 70bac4de
# frozen_string_literal: true
require "spec_helper"
describe "User creates a merge request", :js do
include ProjectForksHelper
let(:approver) { create(:user) }
let(:project) do
create(:project,
:repository,
approvals_before_merge: 1,
merge_requests_template: template_text)
end
let(:template_text) { "This merge request should contain the following." }
let(:title) { "Some feature" }
let(:user) { create(:user) }
let(:user2) { create(:user) }
before do
stub_feature_flags(approval_rules: false)
project.add_maintainer(user)
project.add_maintainer(user2)
project.add_maintainer(approver)
sign_in(user)
project.approvers.create(user_id: approver.id)
visit(project_new_merge_request_path(project))
end
it "creates a merge request" do
allow_any_instance_of(Gitlab::AuthorityAnalyzer).to receive(:calculate).and_return([user2])
find(".js-source-branch").click
click_link("fix")
find(".js-target-branch").click
click_link("feature")
click_button("Compare branches")
expect(find_field("merge_request_description").value).to eq(template_text)
page.within("ul .unsaved-approvers") do
expect(page).to have_content(approver.name)
end
page.within(".suggested-approvers") do
expect(page).to have_content(user2.name)
end
click_link(user2.name)
page.within("ul.approver-list") do
expect(page).to have_content(user2.name)
end
fill_in("Title", with: title)
click_button("Submit merge request")
page.within(".js-issuable-actions") do
click_link("Edit", match: :first)
end
page.within("ul.approver-list") do
expect(page).to have_content(user2.name)
end
end
end
# frozen_string_literal: true
require "spec_helper"
describe 'Merge request > User sees closing issues message', :js do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:issue_1) { create(:issue, project: project)}
let(:issue_2) { create(:issue, project: project)}
let(:merge_request) do
create(
:merge_request,
:simple,
source_project: project,
description: merge_request_description
)
end
before do
project.add_developer(user)
sign_in(user)
visit project_merge_request_path(project, merge_request)
wait_for_requests
end
context 'approvals are enabled while closing issues', :js do
let(:project) { create(:project, :public, :repository, approvals_before_merge: 1) }
let(:merge_request_description) { "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}" }
it 'displays closing issue message exactly one time' do
expect(page).to have_content("Closes #{issue_1.to_reference} and #{issue_2.to_reference}", count: 1)
end
end
end
...@@ -26,4 +26,25 @@ describe 'Merge request > User selects branches for new MR', :js do ...@@ -26,4 +26,25 @@ describe 'Merge request > User selects branches for new MR', :js do
expect(page).to have_content('Approvers') expect(page).to have_content('Approvers')
end end
end end
context 'when approvals are enabled for the target project' do
before do
project.update(approvals_before_merge: 1)
visit project_new_merge_request_path(project, merge_request: { target_branch: 'master', source_branch: 'feature_conflict' })
end
it 'shows approval settings' do
expect(page).to have_content('Approvers')
end
context 'saving the MR' do
it 'shows the saved MR' do
fill_in 'merge_request_title', with: 'Test'
click_button 'Submit merge request'
expect(page).to have_link('Close merge request')
end
end
end
end end
...@@ -3,33 +3,19 @@ require "spec_helper" ...@@ -3,33 +3,19 @@ require "spec_helper"
describe "User creates a merge request", :js do describe "User creates a merge request", :js do
include ProjectForksHelper include ProjectForksHelper
let(:approver) { create(:user) }
let(:project) do
create(:project,
:repository,
approvals_before_merge: 1,
merge_requests_template: template_text)
end
let(:template_text) { "This merge request should contain the following." }
let(:title) { "Some feature" } let(:title) { "Some feature" }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user) }
before do before do
stub_feature_flags(approval_rules: false) stub_feature_flags(approval_rules: false)
project.add_maintainer(user) project.add_maintainer(user)
project.add_maintainer(user2)
project.add_maintainer(approver)
sign_in(user) sign_in(user)
project.approvers.create(user_id: approver.id)
visit(project_new_merge_request_path(project))
end end
it "creates a merge request" do it "creates a merge request" do
allow_any_instance_of(Gitlab::AuthorityAnalyzer).to receive(:calculate).and_return([user2]) visit(project_new_merge_request_path(project))
find(".js-source-branch").click find(".js-source-branch").click
click_link("fix") click_link("fix")
...@@ -39,38 +25,12 @@ describe "User creates a merge request", :js do ...@@ -39,38 +25,12 @@ describe "User creates a merge request", :js do
click_button("Compare branches") click_button("Compare branches")
expect(find_field("merge_request_description").value).to eq(template_text)
# Approvers
page.within("ul .unsaved-approvers") do
expect(page).to have_content(approver.name)
end
page.within(".suggested-approvers") do
expect(page).to have_content(user2.name)
end
click_link(user2.name)
page.within("ul.approver-list") do
expect(page).to have_content(user2.name)
end
# End of approvers
fill_in("Title", with: title) fill_in("Title", with: title)
click_button("Submit merge request") click_button("Submit merge request")
page.within(".merge-request") do page.within(".merge-request") do
expect(page).to have_content(title) expect(page).to have_content(title)
end end
page.within(".js-issuable-actions") do
click_link("Edit", match: :first)
end
page.within("ul.approver-list") do
expect(page).to have_content(user2.name)
end
end end
context "to a forked project" do context "to a forked project" do
......
...@@ -73,18 +73,4 @@ describe 'Merge request > User sees closing issues message', :js do ...@@ -73,18 +73,4 @@ describe 'Merge request > User sees closing issues message', :js do
expect(page).to have_content("Mentions #{issue_2.to_reference}") expect(page).to have_content("Mentions #{issue_2.to_reference}")
end end
end end
context 'approvals are enabled while closing issues', :js do
before do
project.add_developer(user)
end
let(:project) { create(:project, :public, :repository, approvals_before_merge: 1) }
let(:merge_request_description) { "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}" }
it 'displays closing issue message exactly one time' do
wait_for_requests
expect(page).to have_content("Closes #{issue_1.to_reference} and #{issue_2.to_reference}", count: 1)
end
end
end end
...@@ -86,27 +86,6 @@ describe 'Merge request > User selects branches for new MR', :js do ...@@ -86,27 +86,6 @@ describe 'Merge request > User selects branches for new MR', :js do
expect(target_items.count).to be > 1 expect(target_items.count).to be > 1
end end
context 'when approvals are enabled for the target project' do
before do
project.update(approvals_before_merge: 1)
visit project_new_merge_request_path(project, merge_request: { target_branch: 'master', source_branch: 'feature_conflict' })
end
it 'shows approval settings' do
expect(page).to have_content('Approvers')
end
context 'saving the MR' do
it 'shows the saved MR' do
fill_in 'merge_request_title', with: 'Test'
click_button 'Submit merge request'
expect(page).to have_link('Close merge request')
end
end
end
context 'when target project cannot be viewed by the current user' do context 'when target project cannot be viewed by the current user' do
it 'does not leak the private project name & namespace' do it 'does not leak the private project name & namespace' do
private_project = create(:project, :private, :repository) private_project = create(:project, :private, :repository)
......
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