gitlab-org--gitlab-foss/features/steps/project/merge_requests.rb

371 lines
10 KiB
Ruby
Raw Normal View History

class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
2012-09-10 11:35:03 -04:00
include SharedAuthentication
include SharedIssuable
2012-09-10 11:35:03 -04:00
include SharedProject
include SharedNote
include SharedPaths
include SharedMarkdown
include SharedDiffNote
include SharedUser
2012-09-10 11:35:03 -04:00
step 'I click link "New Merge Request"' do
2012-10-29 17:23:49 -04:00
click_link "New Merge Request"
end
step 'I click link "Bug NS-04"' do
2012-10-29 17:23:49 -04:00
click_link "Bug NS-04"
end
step 'I click link "All"' do
2012-10-29 17:23:49 -04:00
click_link "All"
end
step 'I click link "Closed"' do
click_link "Closed"
end
step 'I should see merge request "Wiki Feature"' do
page.within '.merge-request' do
expect(page).to have_content "Wiki Feature"
end
end
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")
2015-06-18 22:13:32 -04:00
expect(merge_request).to be_closed
expect(page).to have_content "Closed by"
end
step 'I should see merge request "Bug NS-04"' do
expect(page).to have_content "Bug NS-04"
end
step 'I should see "Bug NS-04" in merge requests' do
expect(page).to have_content "Bug NS-04"
end
step 'I should see "Feature NS-03" in merge requests' do
expect(page).to have_content "Feature NS-03"
end
step 'I should not see "Feature NS-03" in merge requests' do
expect(page).not_to have_content "Feature NS-03"
end
2012-10-29 17:23:49 -04:00
step 'I should not see "Bug NS-04" in merge requests' do
expect(page).not_to have_content "Bug NS-04"
end
2015-03-16 11:20:17 -04:00
step 'I should see that I am subscribed' do
expect(find('.subscribe-button span')).to have_content 'Unsubscribe'
2015-03-16 11:20:17 -04:00
end
step 'I should see that I am unsubscribed' do
expect(find('.subscribe-button span')).to have_content 'Subscribe'
2015-03-16 11:20:17 -04:00
end
step 'I click button "Unsubscribe"' do
click_on "Unsubscribe"
end
step 'I click link "Close"' do
first(:css, '.close-mr-link').click
end
step 'I submit new merge request "Wiki Feature"' do
select "fix", from: "merge_request_source_branch"
select "feature", from: "merge_request_target_branch"
click_button "Compare branches"
fill_in "merge_request_title", with: "Wiki Feature"
click_button "Submit new merge request"
end
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",
Merge Request on forked projects The good: - You can do a merge request for a forked commit and it will merge properly (i.e. it does work). - Push events take into account merge requests on forked projects - Tests around merge_actions now present, spinach, and other rspec tests - Satellites now clean themselves up rather then recreate The questionable: - Events only know about target projects - Project's merge requests only hold on to MR's where they are the target - All operations performed in the satellite The bad: - Duplication between project's repositories and satellites (e.g. commits_between) (for reference: http://feedback.gitlab.com/forums/176466-general/suggestions/3456722-merge-requests-between-projects-repos) Fixes: Make test repos/satellites only create when needed -Spinach/Rspec now only initialize test directory, and setup stubs (things that are relatively cheap) -project_with_code, source_project_with_code, and target_project_with_code now create/destroy their repos individually -fixed remote removal -How to merge renders properly -Update emails to show project/branches -Edit MR doesn't set target branch -Fix some failures on editing/creating merge requests, added a test -Added back a test around merge request observer -Clean up project_transfer_spec, Remove duplicate enable/disable observers -Ensure satellite lock files are cleaned up, Attempted to add some testing around these as well -Signifant speed ups for tests -Update formatting ordering in notes_on_merge_requests -Remove wiki schema update Fixes for search/search results -Search results was using by_project for a list of projects, updated this to use in_projects -updated search results to reference the correct (target) project -udpated search results to print both sides of the merge request Change-Id: I19407990a0950945cc95d62089cbcc6262dab1a8
2013-04-25 10:15:33 -04:00
source_project: project,
target_project: project,
source_branch: 'fix',
target_branch: 'master',
author: project.users.first,
description: "# Description header"
)
2012-10-29 17:23:49 -04:00
end
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",
Merge Request on forked projects The good: - You can do a merge request for a forked commit and it will merge properly (i.e. it does work). - Push events take into account merge requests on forked projects - Tests around merge_actions now present, spinach, and other rspec tests - Satellites now clean themselves up rather then recreate The questionable: - Events only know about target projects - Project's merge requests only hold on to MR's where they are the target - All operations performed in the satellite The bad: - Duplication between project's repositories and satellites (e.g. commits_between) (for reference: http://feedback.gitlab.com/forums/176466-general/suggestions/3456722-merge-requests-between-projects-repos) Fixes: Make test repos/satellites only create when needed -Spinach/Rspec now only initialize test directory, and setup stubs (things that are relatively cheap) -project_with_code, source_project_with_code, and target_project_with_code now create/destroy their repos individually -fixed remote removal -How to merge renders properly -Update emails to show project/branches -Edit MR doesn't set target branch -Fix some failures on editing/creating merge requests, added a test -Added back a test around merge request observer -Clean up project_transfer_spec, Remove duplicate enable/disable observers -Ensure satellite lock files are cleaned up, Attempted to add some testing around these as well -Signifant speed ups for tests -Update formatting ordering in notes_on_merge_requests -Remove wiki schema update Fixes for search/search results -Search results was using by_project for a list of projects, updated this to use in_projects -updated search results to reference the correct (target) project -udpated search results to print both sides of the merge request Change-Id: I19407990a0950945cc95d62089cbcc6262dab1a8
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)
end
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",
Merge Request on forked projects The good: - You can do a merge request for a forked commit and it will merge properly (i.e. it does work). - Push events take into account merge requests on forked projects - Tests around merge_actions now present, spinach, and other rspec tests - Satellites now clean themselves up rather then recreate The questionable: - Events only know about target projects - Project's merge requests only hold on to MR's where they are the target - All operations performed in the satellite The bad: - Duplication between project's repositories and satellites (e.g. commits_between) (for reference: http://feedback.gitlab.com/forums/176466-general/suggestions/3456722-merge-requests-between-projects-repos) Fixes: Make test repos/satellites only create when needed -Spinach/Rspec now only initialize test directory, and setup stubs (things that are relatively cheap) -project_with_code, source_project_with_code, and target_project_with_code now create/destroy their repos individually -fixed remote removal -How to merge renders properly -Update emails to show project/branches -Edit MR doesn't set target branch -Fix some failures on editing/creating merge requests, added a test -Added back a test around merge request observer -Clean up project_transfer_spec, Remove duplicate enable/disable observers -Ensure satellite lock files are cleaned up, Attempted to add some testing around these as well -Signifant speed ups for tests -Update formatting ordering in notes_on_merge_requests -Remove wiki schema update Fixes for search/search results -Search results was using by_project for a list of projects, updated this to use in_projects -updated search results to reference the correct (target) project -udpated search results to print both sides of the merge request Change-Id: I19407990a0950945cc95d62089cbcc6262dab1a8
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
step 'project "Community" has "Bug CO-01" open merge request with diffs inside' do
project = Project.find_by(name: "Community")
create(:merge_request_with_diffs,
title: "Bug CO-01",
source_project: project,
target_project: project,
author: project.users.first)
end
2015-06-25 21:30:18 -04:00
step 'I click on the Changes tab' do
page.within '.merge-request-tabs' do
click_link 'Changes'
end
2015-06-25 21:30:18 -04:00
# Waits for load
expect(page).to have_css('.tab-content #diffs.active')
end
step 'I should see the proper Inline and Side-by-side links' do
expect(page).to have_css('#parallel-diff-btn', count: 1)
expect(page).to have_css('#inline-diff-btn', count: 1)
end
step 'I switch to the merge request\'s comments tab' do
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
2012-10-29 17:23:49 -04:00
end
step 'I click on the commit in the merge request' do
page.within '.merge-request-tabs' do
click_link 'Commits'
end
page.within '.commits' do
click_link Commit.truncate_sha(sample_commit.id)
end
2012-10-29 17:23:49 -04:00
end
step 'I leave a comment on the diff page' do
init_diff_note
leave_comment "One comment to rule them all"
end
2013-01-15 10:12:53 -05:00
step 'I leave a comment on the diff page in commit' do
click_diff_line(sample_commit.line_code)
leave_comment "One comment to rule them all"
2012-10-29 17:23:49 -04:00
end
step 'I leave a comment like "Line is wrong" on diff' do
init_diff_note
leave_comment "Line is wrong"
end
2012-10-29 17:23:49 -04:00
step 'I leave a comment like "Line is wrong" on diff in commit' do
click_diff_line(sample_commit.line_code)
leave_comment "Line is wrong"
2012-10-29 17:23:49 -04:00
end
step 'I should see a discussion has started on diff' do
2015-06-18 22:13:32 -04:00
page.within(".notes .discussion") do
page.should have_content "#{current_user.name} started a discussion"
page.should have_content sample_commit.line_code_path
page.should have_content "Line is wrong"
end
2012-10-29 17:23:49 -04:00
end
step 'I should see a discussion has started on commit diff' do
2015-06-18 22:13:32 -04:00
page.within(".notes .discussion") do
page.should have_content "#{current_user.name} started a discussion on commit"
page.should have_content sample_commit.line_code_path
page.should have_content "Line is wrong"
end
2012-10-29 17:23:49 -04:00
end
step 'I should see a discussion has started on commit' do
2015-06-18 22:13:32 -04:00
page.within(".notes .discussion") do
page.should have_content "#{current_user.name} started a discussion on commit"
page.should have_content "One comment to rule them all"
end
end
step 'merge request is mergeable' do
expect(page).to have_button 'Accept Merge Request'
end
step 'I modify merge commit message' do
find('.modify-merge-commit-link').click
2014-09-26 18:41:17 -04:00
fill_in '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
page.within '.mr-state-widget' do
2015-01-28 18:36:12 -05:00
click_button "Accept Merge Request"
end
end
step 'I should see merged request' do
page.within '.issue-box' do
expect(page).to have_content "Merged"
end
end
step 'I click link "Reopen"' do
first(:css, '.reopen-mr-link').click
end
step 'I should see reopened merge request "Bug NS-04"' do
page.within '.issue-box' do
expect(page).to have_content "Open"
end
end
step 'I click link "Hide inline discussion" of the third file' do
page.within '.files [id^=diff]:nth-child(3)' do
find('.js-toggle-diff-comments').trigger('click')
end
end
step 'I click link "Show inline discussion" of the third file' do
page.within '.files [id^=diff]:nth-child(3)' do
find('.js-toggle-diff-comments').trigger('click')
end
end
step 'I should not see a comment like "Line is wrong" in the third file' do
page.within '.files [id^=diff]:nth-child(3)' do
expect(page).not_to have_visible_content "Line is wrong"
end
end
step 'I should see a comment like "Line is wrong" in the third file' do
page.within '.files [id^=diff]:nth-child(3) .note-body > .note-text' do
expect(page).to have_visible_content "Line is wrong"
end
end
step 'I should not see a comment like "Line is wrong here" in the third file' do
page.within '.files [id^=diff]:nth-child(3)' do
expect(page).not_to have_visible_content "Line is wrong here"
end
end
step 'I should see a comment like "Line is wrong here" in the third file' do
page.within '.files [id^=diff]:nth-child(3) .note-body > .note-text' do
expect(page).to have_visible_content "Line is wrong here"
end
end
step 'I leave a comment like "Line is correct" on line 12 of the second file' do
init_diff_note_first_file
page.within(".js-discussion-note-form") do
fill_in "note_note", with: "Line is correct"
click_button "Add Comment"
end
page.within ".files [id^=diff]:nth-child(2) .note-body > .note-text" do
expect(page).to have_content "Line is correct"
end
end
step 'I leave a comment like "Line is wrong" on line 39 of the third file' do
init_diff_note_second_file
page.within(".js-discussion-note-form") do
fill_in "note_note", with: "Line is wrong on here"
click_button "Add Comment"
end
end
step 'I should still see a comment like "Line is correct" in the second file' do
page.within '.files [id^=diff]:nth-child(2) .note-body > .note-text' do
expect(page).to have_visible_content "Line is correct"
end
end
2014-08-02 11:12:01 -04:00
step 'I unfold diff' do
2015-06-25 21:30:18 -04:00
expect(page).to have_css('.js-unfold')
2014-08-02 11:12:01 -04:00
first('.js-unfold').click
end
step 'I should see additional file lines' do
expect(first('.text-file')).to have_content('.bundle')
end
2014-09-12 14:12:31 -04:00
step 'I click Side-by-side Diff tab' do
find('a', text: 'Side-by-side').trigger('click')
2014-09-12 14:12:31 -04:00
end
step 'I should see comments on the side-by-side diff page' do
page.within '.files [id^=diff]:nth-child(2) .parallel .note-body > .note-text' do
expect(page).to have_visible_content "Line is correct"
2014-09-12 14:12:31 -04:00
end
end
step 'I fill in merge request search with "Fe"' do
fill_in 'issue_search', with: "Fe"
end
step 'I click the "Target branch" dropdown' do
first('.target_branch').click
end
step 'I select a new target branch' do
select "feature", from: "merge_request_target_branch"
click_button 'Save'
end
step 'I should see new target branch changes' do
2015-08-10 08:15:27 -04:00
expect(page).to have_content 'Request to merge fix into feature'
expect(page).to have_content 'Target branch changed from master to feature'
end
step 'I click on "Email Patches"' do
click_link "Email Patches"
end
step 'I click on "Plain Diff"' do
click_link "Plain Diff"
end
step 'I should see a patch diff' do
expect(page).to have_content('diff --git')
end
def merge_request
2014-01-19 13:55:59 -05:00
@merge_request ||= MergeRequest.find_by!(title: "Bug NS-05")
end
def init_diff_note
click_diff_line(sample_commit.line_code)
end
def leave_comment(message)
2015-06-18 22:13:32 -04:00
page.within(".js-discussion-note-form", visible: true) do
fill_in "note_note", with: message
click_button "Add Comment"
end
2015-06-18 22:13:32 -04:00
page.within(".notes_holder", visible: true) do
expect(page).to have_content message
end
end
def init_diff_note_first_file
click_diff_line(sample_compare.changes[0][:line_code])
end
def init_diff_note_second_file
click_diff_line(sample_compare.changes[1][:line_code])
end
def have_visible_content (text)
have_css("*", text: text, visible: true)
end
end