2018-05-14 07:44:26 +00:00
|
|
|
require "spec_helper"
|
2017-10-04 22:31:34 +00:00
|
|
|
|
2018-05-14 07:44:26 +00:00
|
|
|
describe "User creates a merge request", :js do
|
|
|
|
include ProjectForksHelper
|
|
|
|
|
|
|
|
let(:title) { "Some feature" }
|
2017-10-04 22:31:34 +00:00
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-10-04 22:31:34 +00:00
|
|
|
sign_in(user)
|
2018-05-14 07:44:26 +00:00
|
|
|
end
|
2017-10-04 22:31:34 +00:00
|
|
|
|
2018-05-14 07:44:26 +00:00
|
|
|
it "creates a merge request" do
|
2017-10-04 22:31:34 +00:00
|
|
|
visit(project_new_merge_request_path(project))
|
|
|
|
|
2018-05-14 07:44:26 +00:00
|
|
|
find(".js-source-branch").click
|
|
|
|
click_link("fix")
|
2017-10-04 22:31:34 +00:00
|
|
|
|
2018-05-14 07:44:26 +00:00
|
|
|
find(".js-target-branch").click
|
|
|
|
click_link("feature")
|
2017-10-04 22:31:34 +00:00
|
|
|
|
2018-05-14 07:44:26 +00:00
|
|
|
click_button("Compare branches")
|
2017-10-04 22:31:34 +00:00
|
|
|
|
2018-05-14 07:44:26 +00:00
|
|
|
fill_in("Title", with: title)
|
|
|
|
click_button("Submit merge request")
|
2017-10-04 22:31:34 +00:00
|
|
|
|
2018-05-14 07:44:26 +00:00
|
|
|
page.within(".merge-request") do
|
|
|
|
expect(page).to have_content(title)
|
2017-10-04 22:31:34 +00:00
|
|
|
end
|
2018-05-14 07:44:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context "to a forked project" do
|
|
|
|
let(:forked_project) { fork_project(project, user, namespace: user.namespace, repository: true) }
|
|
|
|
|
|
|
|
it "creates a merge request" do
|
|
|
|
visit(project_new_merge_request_path(forked_project))
|
|
|
|
|
|
|
|
expect(page).to have_content("Source branch").and have_content("Target branch")
|
|
|
|
expect(find("#merge_request_target_project_id", visible: false).value).to eq(project.id.to_s)
|
|
|
|
|
|
|
|
click_button("Compare branches and continue")
|
|
|
|
|
|
|
|
expect(page).to have_content("You must select source and target branch")
|
|
|
|
|
|
|
|
first(".js-source-project").click
|
|
|
|
first(".dropdown-source-project a", text: forked_project.full_path)
|
|
|
|
|
|
|
|
first(".js-target-project").click
|
|
|
|
first(".dropdown-target-project a", text: project.full_path)
|
|
|
|
|
|
|
|
first(".js-source-branch").click
|
2017-10-04 22:31:34 +00:00
|
|
|
|
2018-05-14 07:44:26 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
source_branch = "fix"
|
|
|
|
|
|
|
|
first(".js-source-branch-dropdown .dropdown-content a", text: source_branch).click
|
|
|
|
|
|
|
|
click_button("Compare branches and continue")
|
|
|
|
|
|
|
|
expect(page).to have_css("h3.page-title", text: "New Merge Request")
|
|
|
|
|
|
|
|
page.within("form#new_merge_request") do
|
|
|
|
fill_in("Title", with: title)
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(find(".js-assignee-search")["data-project-id"]).to eq(project.id.to_s)
|
2019-04-07 18:35:16 +00:00
|
|
|
find('.js-assignee-search').click
|
2018-05-14 07:44:26 +00:00
|
|
|
|
|
|
|
page.within(".dropdown-menu-user") do
|
|
|
|
expect(page).to have_content("Unassigned")
|
|
|
|
.and have_content(user.name)
|
|
|
|
.and have_content(project.users.first.name)
|
|
|
|
end
|
2019-04-07 18:35:16 +00:00
|
|
|
find('.js-assignee-search').click
|
2018-05-14 07:44:26 +00:00
|
|
|
|
|
|
|
click_button("Submit merge request")
|
|
|
|
|
|
|
|
expect(page).to have_content(title).and have_content("Request to merge #{user.namespace.name}:#{source_branch} into master")
|
|
|
|
end
|
2017-10-04 22:31:34 +00:00
|
|
|
end
|
|
|
|
end
|