debian-mirror-gitlab/features/steps/project/forked_merge_requests.rb

140 lines
5.3 KiB
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps
2014-09-02 18:07:02 +05:30
include SharedAuthentication
include SharedProject
include SharedNote
include SharedPaths
include Select2Helper
2017-09-10 17:25:29 +05:30
include WaitForRequests
2018-03-17 18:26:18 +05:30
include ProjectForksHelper
2014-09-02 18:07:02 +05:30
step 'I am a member of project "Shop"' do
2017-08-17 22:00:37 +05:30
@project = ::Project.find_by(name: "Shop")
@project ||= create(:project, :repository, name: "Shop")
2018-03-17 18:26:18 +05:30
@project.add_reporter(@user)
2014-09-02 18:07:02 +05:30
end
step 'I have a project forked off of "Shop" called "Forked Shop"' do
2018-03-17 18:26:18 +05:30
@forked_project = fork_project(@project, @user,
namespace: @user.namespace,
repository: true)
2014-09-02 18:07:02 +05:30
end
step 'I click link "New Merge Request"' do
2017-09-10 17:25:29 +05:30
page.within '#content-body' do
page.has_link?('New Merge Request') ? click_link("New Merge Request") : click_link('New merge request')
end
2014-09-02 18:07:02 +05:30
end
step 'I should see merge request "Merge Request On Forked Project"' do
2015-09-11 14:41:01 +05:30
expect(@project.merge_requests.size).to be >= 1
2014-09-02 18:07:02 +05:30
@merge_request = @project.merge_requests.last
2017-09-10 17:25:29 +05:30
expect(current_path).to eq project_merge_request_path(@project, @merge_request)
2015-09-11 14:41:01 +05:30
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"
2017-09-10 17:25:29 +05:30
expect(page).to have_content @forked_project.full_path
expect(page).to have_content @project.full_path
2015-09-11 14:41:01 +05:30
expect(page).to have_content @merge_request.source_branch
expect(page).to have_content @merge_request.target_branch
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
wait_for_requests
2014-09-02 18:07:02 +05:30
end
step 'I fill out a "Merge Request On Forked Project" merge request' do
2016-09-13 17:45:13 +05:30
expect(page).to have_content('Source branch')
expect(page).to have_content('Target branch')
2016-06-02 11:05:42 +05:30
first('.js-source-project').click
2017-09-10 17:25:29 +05:30
first('.dropdown-source-project a', text: @forked_project.full_path)
2016-06-02 11:05:42 +05:30
first('.js-target-project').click
2017-09-10 17:25:29 +05:30
first('.dropdown-target-project a', text: @project.full_path)
2016-06-02 11:05:42 +05:30
first('.js-source-branch').click
2017-09-10 17:25:29 +05:30
wait_for_requests
2016-06-02 11:05:42 +05:30
first('.dropdown-source-branch .dropdown-content a', text: 'fix').click
2014-09-02 18:07:02 +05:30
2015-12-23 02:04:40 +05:30
click_button "Compare branches and continue"
expect(page).to have_css("h3.page-title", text: "New Merge Request")
2014-09-02 18:07:02 +05:30
2016-04-02 18:10:28 +05:30
page.within 'form#new_merge_request' do
fill_in "merge_request_title", with: "Merge Request On Forked Project"
end
2014-09-02 18:07:02 +05:30
end
step 'I submit the merge request' do
2015-12-23 02:04:40 +05:30
click_button "Submit merge request"
2014-09-02 18:07:02 +05:30
end
step 'I update the merge request title' do
fill_in "merge_request_title", with: "An Edited Forked Merge Request"
end
step 'I save the merge request' do
click_button "Save changes"
end
step 'I should see the edited merge request' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "An Edited Forked Merge Request"
expect(@project.merge_requests.size).to be >= 1
2014-09-02 18:07:02 +05:30
@merge_request = @project.merge_requests.last
2017-09-10 17:25:29 +05:30
expect(current_path).to eq project_merge_request_path(@project, @merge_request)
2015-09-11 14:41:01 +05:30
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"
2017-09-10 17:25:29 +05:30
expect(page).to have_content @forked_project.full_path
expect(page).to have_content @project.full_path
2015-09-11 14:41:01 +05:30
expect(page).to have_content @merge_request.source_branch
expect(page).to have_content @merge_request.target_branch
2014-09-02 18:07:02 +05:30
end
step 'I should see last push widget' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "You pushed to new_design"
expect(page).to have_link "Create Merge Request"
2014-09-02 18:07:02 +05:30
end
step 'I click link edit "Merge Request On Forked Project"' do
find("#edit_merge_request").click
end
step 'I see the edit page prefilled for "Merge Request On Forked Project"' do
2017-09-10 17:25:29 +05:30
expect(current_path).to eq edit_project_merge_request_path(@project, @merge_request)
2016-06-02 11:05:42 +05:30
expect(page).to have_content "Edit merge request #{@merge_request.to_reference}"
2015-09-11 14:41:01 +05:30
expect(find("#merge_request_title").value).to eq "Merge Request On Forked Project"
2014-09-02 18:07:02 +05:30
end
step 'I fill out an invalid "Merge Request On Forked Project" merge request' do
2016-06-02 11:05:42 +05:30
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-09-02 18:07:02 +05:30
click_button "Compare branches"
end
step 'I should see validation errors' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "You must select source and target branch"
2014-09-02 18:07:02 +05:30
end
step 'the target repository should be the original repository' do
2016-06-02 11:05:42 +05:30
expect(find_by_id("merge_request_target_project_id").value).to eq "#{@project.id}"
2015-09-11 14:41:01 +05:30
end
step 'I click "Assign to" dropdown"' do
2016-11-03 12:29:30 +05:30
click_button 'Assignee'
2015-09-11 14:41:01 +05:30
end
step 'I should see the target project ID in the input selector' do
2016-11-03 12:29:30 +05:30
expect(find('.js-assignee-search')["data-project-id"]).to eq "#{@project.id}"
2015-09-11 14:41:01 +05:30
end
step 'I should see the users from the target project ID' do
2016-11-03 12:29:30 +05:30
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
2014-09-02 18:07:02 +05:30
end
end