2012-09-10 09:35:23 -04:00
|
|
|
class ProjectMergeRequests < Spinach::FeatureSteps
|
2012-09-10 11:35:03 -04:00
|
|
|
include SharedAuthentication
|
|
|
|
include SharedProject
|
|
|
|
include SharedNote
|
|
|
|
include SharedPaths
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I click link "New Merge Request"' do
|
2012-10-29 17:23:49 -04:00
|
|
|
click_link "New Merge Request"
|
2012-09-10 09:35:23 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I click link "Bug NS-04"' do
|
2012-10-29 17:23:49 -04:00
|
|
|
click_link "Bug NS-04"
|
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I click link "All"' do
|
2012-10-29 17:23:49 -04:00
|
|
|
click_link "All"
|
2012-09-10 09:35:23 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I click link "Closed"' do
|
2012-09-10 09:35:23 -04:00
|
|
|
click_link "Closed"
|
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I should see merge request "Wiki Feature"' do
|
2013-10-21 02:55:41 -04:00
|
|
|
within '.merge-request' do
|
|
|
|
page.should have_content "Wiki Feature"
|
|
|
|
end
|
2012-09-10 09:35:23 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I should see closed merge request "Bug NS-04"' do
|
2014-01-19 13:55:59 -05:00
|
|
|
merge_request = MergeRequest.find_by!(title: "Bug NS-04")
|
2013-02-28 02:43:48 -05:00
|
|
|
merge_request.closed?.should be_true
|
2012-10-29 17:23:49 -04:00
|
|
|
page.should have_content "Closed by"
|
2012-09-10 09:35:23 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I should see merge request "Bug NS-04"' do
|
2012-10-29 17:23:49 -04:00
|
|
|
page.should have_content "Bug NS-04"
|
2012-09-10 09:35:23 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I should see "Bug NS-04" in merge requests' do
|
2012-10-29 17:23:49 -04:00
|
|
|
page.should have_content "Bug NS-04"
|
2012-09-10 09:35:23 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I should see "Feature NS-03" in merge requests' do
|
2012-10-29 17:23:49 -04:00
|
|
|
page.should have_content "Feature NS-03"
|
2012-09-10 09:35:23 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I should not see "Feature NS-03" in merge requests' do
|
2012-10-29 17:23:49 -04:00
|
|
|
page.should_not have_content "Feature NS-03"
|
2012-09-10 09:35:23 -04:00
|
|
|
end
|
|
|
|
|
2012-10-29 17:23:49 -04:00
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I should not see "Bug NS-04" in merge requests' do
|
2012-10-29 17:23:49 -04:00
|
|
|
page.should_not have_content "Bug NS-04"
|
2012-09-10 09:35:23 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I click link "Close"' do
|
2012-10-29 17:23:49 -04:00
|
|
|
click_link "Close"
|
2012-09-10 09:35:23 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I submit new merge request "Wiki Feature"' do
|
2013-10-21 02:55:41 -04:00
|
|
|
fill_in "merge_request_title", with: "Wiki Feature"
|
|
|
|
|
|
|
|
# this must come first, so that the target branch is set
|
|
|
|
# by the time the "select" for "notes_refactoring" is executed
|
|
|
|
select project.path_with_namespace, from: "merge_request_target_project_id"
|
|
|
|
select "master", from: "merge_request_source_branch"
|
|
|
|
|
2013-06-26 16:45:57 -04:00
|
|
|
find(:select, "merge_request_target_project_id", {}).value.should == project.id.to_s
|
|
|
|
find(:select, "merge_request_source_project_id", {}).value.should == project.id.to_s
|
|
|
|
|
2013-10-21 02:55:41 -04:00
|
|
|
# using "notes_refactoring" because "Bug NS-04" uses master/stable,
|
|
|
|
# this will fail merge_request validation if the branches are the same
|
2013-06-26 16:45:57 -04:00
|
|
|
find(:select, "merge_request_target_branch", {}).find(:option, "notes_refactoring", {}).value.should == "notes_refactoring"
|
2013-10-21 02:55:41 -04:00
|
|
|
select "notes_refactoring", from: "merge_request_target_branch"
|
2013-06-26 16:45:57 -04:00
|
|
|
|
2013-01-05 17:08:02 -05:00
|
|
|
click_button "Submit merge request"
|
2012-09-10 09:35:23 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'project "Shop" have "Bug NS-04" open merge request' do
|
2013-02-18 07:49:56 -05:00
|
|
|
create(:merge_request,
|
2012-10-29 17:23:49 -04:00
|
|
|
title: "Bug NS-04",
|
2013-04-25 10:15:33 -04:00
|
|
|
source_project: project,
|
|
|
|
target_project: project,
|
2014-01-23 05:55:43 -05:00
|
|
|
source_branch: 'stable',
|
|
|
|
target_branch: 'master',
|
2012-10-29 17:23:49 -04:00
|
|
|
author: project.users.first)
|
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'project "Shop" have "Bug NS-05" open merge request with diffs inside' do
|
2012-10-29 17:23:49 -04:00
|
|
|
create(:merge_request_with_diffs,
|
|
|
|
title: "Bug NS-05",
|
2013-04-25 10:15:33 -04:00
|
|
|
source_project: project,
|
|
|
|
target_project: project,
|
2012-10-29 17:23:49 -04:00
|
|
|
author: project.users.first)
|
2012-09-10 09:35:23 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'project "Shop" have "Feature NS-03" closed merge request' do
|
2013-02-18 05:43:08 -05:00
|
|
|
create(:closed_merge_request,
|
2012-10-29 17:23:49 -04:00
|
|
|
title: "Feature NS-03",
|
2013-04-25 10:15:33 -04:00
|
|
|
source_project: project,
|
|
|
|
target_project: project,
|
2013-02-18 05:43:08 -05:00
|
|
|
author: project.users.first)
|
2012-10-29 17:23:49 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I switch to the diff tab' do
|
2013-02-28 14:02:41 -05:00
|
|
|
visit diffs_project_merge_request_path(project, merge_request)
|
2012-10-29 17:23:49 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I switch to the merge request\'s comments tab' do
|
2013-02-28 14:02:41 -05:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2012-10-29 17:23:49 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I click on the first commit in the merge request' do
|
2014-01-23 05:55:43 -05:00
|
|
|
within '.first-commits' do
|
|
|
|
click_link merge_request.commits.first.short_id(8)
|
|
|
|
end
|
2012-10-29 17:23:49 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I leave a comment on the diff page' do
|
2013-04-11 03:45:18 -04:00
|
|
|
init_diff_note
|
2014-01-23 05:55:43 -05:00
|
|
|
leave_comment "One comment to rule them all"
|
|
|
|
end
|
2013-01-15 10:12:53 -05:00
|
|
|
|
2014-01-23 05:55:43 -05:00
|
|
|
step 'I leave a comment on the diff page in commit' do
|
|
|
|
find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click
|
|
|
|
leave_comment "One comment to rule them all"
|
2012-10-29 17:23:49 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I leave a comment like "Line is wrong" on line 185 of the first file' do
|
2013-04-11 03:45:18 -04:00
|
|
|
init_diff_note
|
2014-01-23 05:55:43 -05:00
|
|
|
leave_comment "Line is wrong"
|
|
|
|
end
|
2012-10-29 17:23:49 -04:00
|
|
|
|
2014-01-23 05:55:43 -05:00
|
|
|
step 'I leave a comment like "Line is wrong" on line 185 of the first file in commit' do
|
|
|
|
find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click
|
|
|
|
leave_comment "Line is wrong"
|
2012-10-29 17:23:49 -04:00
|
|
|
end
|
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'I should see a discussion has started on line 185' do
|
2012-10-29 17:23:49 -04:00
|
|
|
page.should have_content "#{current_user.name} started a discussion on this merge request diff"
|
2013-04-03 15:04:26 -04:00
|
|
|
page.should have_content "app/assets/stylesheets/tree.scss:L185"
|
2012-10-29 17:23:49 -04:00
|
|
|
page.should have_content "Line is wrong"
|
|
|
|
end
|
|
|
|
|
2014-01-23 05:55:43 -05:00
|
|
|
step 'I should see a discussion has started on commit b1e6a9dbf1:L185' do
|
2012-10-29 17:23:49 -04:00
|
|
|
page.should have_content "#{current_user.name} started a discussion on commit"
|
2013-04-03 15:04:26 -04:00
|
|
|
page.should have_content "app/assets/stylesheets/tree.scss:L185"
|
2012-10-29 17:23:49 -04:00
|
|
|
page.should have_content "Line is wrong"
|
|
|
|
end
|
|
|
|
|
2014-01-23 05:55:43 -05:00
|
|
|
step 'I should see a discussion has started on commit b1e6a9dbf1' do
|
|
|
|
page.should have_content "#{current_user.name} started a discussion on commit"
|
2012-10-29 17:23:49 -04:00
|
|
|
page.should have_content "One comment to rule them all"
|
2013-04-03 15:04:26 -04:00
|
|
|
page.should have_content "app/assets/stylesheets/tree.scss:L185"
|
2012-09-10 09:35:23 -04:00
|
|
|
end
|
2013-02-28 02:43:48 -05:00
|
|
|
|
2014-01-14 04:49:54 -05:00
|
|
|
step 'merge request is mergeable' do
|
|
|
|
page.should have_content 'You can accept this request automatically'
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I modify merge commit message' do
|
|
|
|
find('.modify-merge-commit-link').click
|
|
|
|
fill_in 'merge_commit_message', with: "wow such merge"
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'merge request "Bug NS-05" is mergeable' do
|
|
|
|
merge_request.mark_as_mergeable
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I accept this merge request' do
|
|
|
|
click_button "Accept Merge Request"
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should see merged request' do
|
|
|
|
within '.page-title' do
|
|
|
|
page.should have_content "Merged"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-02-28 02:43:48 -05:00
|
|
|
def project
|
2014-01-19 13:55:59 -05:00
|
|
|
@project ||= Project.find_by!(name: "Shop")
|
2013-02-28 02:43:48 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def merge_request
|
2014-01-19 13:55:59 -05:00
|
|
|
@merge_request ||= MergeRequest.find_by!(title: "Bug NS-05")
|
2013-02-28 02:43:48 -05:00
|
|
|
end
|
2013-04-11 03:45:18 -04:00
|
|
|
|
|
|
|
def init_diff_note
|
2014-01-23 05:55:43 -05:00
|
|
|
find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185"]').click
|
|
|
|
end
|
|
|
|
|
|
|
|
def leave_comment(message)
|
|
|
|
within(".js-discussion-note-form") do
|
|
|
|
fill_in "note_note", with: message
|
|
|
|
click_button "Add Comment"
|
|
|
|
end
|
|
|
|
|
|
|
|
within ".note-text" do
|
|
|
|
page.should have_content message
|
|
|
|
end
|
2013-04-11 03:45:18 -04:00
|
|
|
end
|
2012-09-10 09:35:23 -04:00
|
|
|
end
|