2014-09-22 10:30:25 -04:00
|
|
|
class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps
|
2013-04-25 10:15:33 -04:00
|
|
|
include SharedAuthentication
|
|
|
|
include SharedProject
|
|
|
|
include SharedNote
|
|
|
|
include SharedPaths
|
2014-01-11 09:05:41 -05:00
|
|
|
include Select2Helper
|
2013-04-25 10:15:33 -04:00
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I am a member of project "Shop"' do
|
2014-01-19 13:55:59 -05:00
|
|
|
@project = Project.find_by(name: "Shop")
|
2014-01-22 14:03:52 -05:00
|
|
|
@project ||= create(:project, name: "Shop")
|
2013-04-25 10:15:33 -04:00
|
|
|
@project.team << [@user, :reporter]
|
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I have a project forked off of "Shop" called "Forked Shop"' do
|
2014-07-31 13:13:27 -04:00
|
|
|
@forked_project = Projects::ForkService.new(@project, @user).execute
|
2013-04-25 10:15:33 -04:00
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I click link "New Merge Request"' do
|
2013-04-25 10:15:33 -04:00
|
|
|
click_link "New Merge Request"
|
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I should see merge request "Merge Request On Forked Project"' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(@project.merge_requests.size).to be >= 1
|
2013-04-25 10:15:33 -04:00
|
|
|
@merge_request = @project.merge_requests.last
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(current_path).to eq namespace_project_merge_request_path(@project.namespace, @project, @merge_request)
|
|
|
|
expect(@merge_request.title).to eq "Merge Request On Forked Project"
|
|
|
|
expect(@merge_request.source_project).to eq @forked_project
|
|
|
|
expect(@merge_request.source_branch).to eq "fix"
|
|
|
|
expect(@merge_request.target_branch).to eq "master"
|
|
|
|
expect(page).to have_content @forked_project.path_with_namespace
|
|
|
|
expect(page).to have_content @project.path_with_namespace
|
|
|
|
expect(page).to have_content @merge_request.source_branch
|
|
|
|
expect(page).to have_content @merge_request.target_branch
|
2013-04-25 10:15:33 -04:00
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I fill out a "Merge Request On Forked Project" merge request' do
|
2016-08-11 12:48:32 -04:00
|
|
|
expect(page).to have_content('Source branch')
|
|
|
|
expect(page).to have_content('Target branch')
|
|
|
|
|
2016-04-06 07:52:07 -04:00
|
|
|
first('.js-source-project').click
|
|
|
|
first('.dropdown-source-project a', text: @forked_project.path_with_namespace)
|
|
|
|
|
|
|
|
first('.js-target-project').click
|
|
|
|
first('.dropdown-target-project a', text: @project.path_with_namespace)
|
|
|
|
|
|
|
|
first('.js-source-branch').click
|
|
|
|
first('.dropdown-source-branch .dropdown-content a', text: 'fix').click
|
2013-06-06 17:22:36 -04:00
|
|
|
|
2015-12-02 08:33:14 -05:00
|
|
|
click_button "Compare branches and continue"
|
2013-06-03 16:20:50 -04:00
|
|
|
|
2015-12-16 14:55:48 -05:00
|
|
|
expect(page).to have_css("h3.page-title", text: "New Merge Request")
|
|
|
|
|
2016-01-15 18:29:29 -05:00
|
|
|
page.within 'form#new_merge_request' do
|
|
|
|
fill_in "merge_request_title", with: "Merge Request On Forked Project"
|
|
|
|
end
|
2013-04-25 10:15:33 -04:00
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I submit the merge request' do
|
2015-12-03 08:54:14 -05:00
|
|
|
click_button "Submit merge request"
|
2013-04-25 10:15:33 -04:00
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I follow the target commit link' do
|
2013-04-25 10:15:33 -04:00
|
|
|
commit = @project.repository.commit
|
|
|
|
click_link commit.short_id(8)
|
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I should see the commit under the forked from project' do
|
2013-04-25 10:15:33 -04:00
|
|
|
commit = @project.repository.commit
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).to have_content(commit.message)
|
2013-04-25 10:15:33 -04:00
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I click "Create Merge Request on fork" link' do
|
2013-04-25 10:15:33 -04:00
|
|
|
click_link "Create Merge Request on fork"
|
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I see prefilled new Merge Request page for the forked project' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(current_path).to eq new_namespace_project_merge_request_path(@forked_project.namespace, @forked_project)
|
|
|
|
expect(find("#merge_request_source_project_id").value).to eq @forked_project.id.to_s
|
|
|
|
expect(find("#merge_request_target_project_id").value).to eq @project.id.to_s
|
|
|
|
expect(find("#merge_request_source_branch").value).to have_content "new_design"
|
|
|
|
expect(find("#merge_request_target_branch").value).to have_content "master"
|
|
|
|
expect(find("#merge_request_title").value).to eq "New Design"
|
2015-02-06 12:19:51 -05:00
|
|
|
verify_commit_link(".mr_target_commit", @project)
|
|
|
|
verify_commit_link(".mr_source_commit", @forked_project)
|
2013-04-25 10:15:33 -04:00
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I update the merge request title' do
|
2013-07-17 17:40:40 -04:00
|
|
|
fill_in "merge_request_title", with: "An Edited Forked Merge Request"
|
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I save the merge request' do
|
2013-07-17 17:40:40 -04:00
|
|
|
click_button "Save changes"
|
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I should see the edited merge request' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).to have_content "An Edited Forked Merge Request"
|
|
|
|
expect(@project.merge_requests.size).to be >= 1
|
2013-07-17 17:40:40 -04:00
|
|
|
@merge_request = @project.merge_requests.last
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(current_path).to eq namespace_project_merge_request_path(@project.namespace, @project, @merge_request)
|
|
|
|
expect(@merge_request.source_project).to eq @forked_project
|
|
|
|
expect(@merge_request.source_branch).to eq "fix"
|
|
|
|
expect(@merge_request.target_branch).to eq "master"
|
|
|
|
expect(page).to have_content @forked_project.path_with_namespace
|
|
|
|
expect(page).to have_content @project.path_with_namespace
|
|
|
|
expect(page).to have_content @merge_request.source_branch
|
|
|
|
expect(page).to have_content @merge_request.target_branch
|
2013-07-17 17:40:40 -04:00
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I should see last push widget' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).to have_content "You pushed to new_design"
|
|
|
|
expect(page).to have_link "Create Merge Request"
|
2013-04-25 10:15:33 -04:00
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I click link edit "Merge Request On Forked Project"' do
|
2013-06-03 16:20:50 -04:00
|
|
|
find("#edit_merge_request").click
|
2013-04-25 10:15:33 -04:00
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I see the edit page prefilled for "Merge Request On Forked Project"' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(current_path).to eq edit_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)
|
2016-04-19 02:32:02 -04:00
|
|
|
expect(page).to have_content "Edit merge request #{@merge_request.to_reference}"
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(find("#merge_request_title").value).to eq "Merge Request On Forked Project"
|
2013-04-25 10:15:33 -04:00
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I fill out an invalid "Merge Request On Forked Project" merge request' do
|
2016-04-06 07:52:07 -04:00
|
|
|
expect(find_by_id("merge_request_source_project_id", visible: false).value).to eq @forked_project.id.to_s
|
|
|
|
expect(find_by_id("merge_request_target_project_id", visible: false).value).to eq @project.id.to_s
|
|
|
|
expect(find_by_id("merge_request_source_branch", visible: false).value).to eq nil
|
|
|
|
expect(find_by_id("merge_request_target_branch", visible: false).value).to eq "master"
|
2014-05-08 12:00:03 -04:00
|
|
|
click_button "Compare branches"
|
2013-06-08 11:51:18 -04:00
|
|
|
end
|
|
|
|
|
2013-08-08 08:14:59 -04:00
|
|
|
step 'I should see validation errors' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).to have_content "You must select source and target branch"
|
2013-11-28 03:45:35 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'the target repository should be the original repository' do
|
2016-04-06 07:52:07 -04:00
|
|
|
expect(find_by_id("merge_request_target_project_id").value).to eq "#{@project.id}"
|
2013-06-08 11:51:18 -04:00
|
|
|
end
|
|
|
|
|
2015-05-19 23:46:48 -04:00
|
|
|
step 'I click "Assign to" dropdown"' do
|
2016-07-16 03:12:12 -04:00
|
|
|
click_button 'Assignee'
|
2015-05-19 23:46:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should see the target project ID in the input selector' do
|
2016-07-16 03:12:12 -04:00
|
|
|
expect(find('.js-assignee-search')["data-project-id"]).to eq "#{@project.id}"
|
2015-05-19 23:46:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should see the users from the target project ID' do
|
2016-07-20 04:45:53 -04:00
|
|
|
page.within '.dropdown-menu-user' do
|
|
|
|
expect(page).to have_content 'Unassigned'
|
|
|
|
expect(page).to have_content current_user.name
|
|
|
|
expect(page).to have_content @project.users.first.name
|
|
|
|
end
|
2015-05-19 23:46:48 -04:00
|
|
|
end
|
|
|
|
|
2013-09-11 13:27:50 -04:00
|
|
|
# Verify a link is generated against the correct project
|
2013-06-03 16:20:50 -04:00
|
|
|
def verify_commit_link(container_div, container_project)
|
2013-09-11 13:27:50 -04:00
|
|
|
# This should force a wait for the javascript to execute
|
2016-06-29 09:23:44 -04:00
|
|
|
expect(find(:div, container_div).find(".commit_short_id")['href']).to have_content "#{container_project.path_with_namespace}/commit"
|
2013-06-03 16:20:50 -04:00
|
|
|
end
|
2013-04-25 10:15:33 -04:00
|
|
|
end
|