2014-10-17 00:10:50 -04:00
|
|
|
module SharedIssuable
|
|
|
|
include Spinach::DSL
|
|
|
|
|
|
|
|
def edit_issuable
|
2016-04-01 08:44:22 -04:00
|
|
|
find('.issuable-edit', visible: true).click
|
2014-10-17 00:10:50 -04:00
|
|
|
end
|
|
|
|
|
2016-01-13 10:38:42 -05:00
|
|
|
step 'project "Community" has "Community issue" open issue' do
|
|
|
|
create_issuable_for_project(
|
|
|
|
project_name: 'Community',
|
|
|
|
title: 'Community issue'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'project "Community" has "Community fix" open merge request' do
|
|
|
|
create_issuable_for_project(
|
|
|
|
project_name: 'Community',
|
|
|
|
type: :merge_request,
|
|
|
|
title: 'Community fix'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'project "Enterprise" has "Enterprise issue" open issue' do
|
|
|
|
create_issuable_for_project(
|
|
|
|
project_name: 'Enterprise',
|
|
|
|
title: 'Enterprise issue'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'project "Enterprise" has "Enterprise fix" open merge request' do
|
|
|
|
create_issuable_for_project(
|
|
|
|
project_name: 'Enterprise',
|
|
|
|
type: :merge_request,
|
|
|
|
title: 'Enterprise fix'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I leave a comment referencing issue "Community issue"' do
|
|
|
|
leave_reference_comment(
|
|
|
|
issuable: Issue.find_by(title: 'Community issue'),
|
|
|
|
from_project_name: 'Enterprise'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I leave a comment referencing issue "Community fix"' do
|
|
|
|
leave_reference_comment(
|
|
|
|
issuable: MergeRequest.find_by(title: 'Community fix'),
|
|
|
|
from_project_name: 'Enterprise'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I visit issue page "Enterprise issue"' do
|
|
|
|
issue = Issue.find_by(title: 'Enterprise issue')
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_issue_path(issue.project, issue)
|
2016-01-13 10:38:42 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I visit merge request page "Enterprise fix"' do
|
|
|
|
mr = MergeRequest.find_by(title: 'Enterprise fix')
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_merge_request_path(mr.target_project, mr)
|
2016-01-13 10:38:42 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I visit issue page "Community issue"' do
|
|
|
|
issue = Issue.find_by(title: 'Community issue')
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_issue_path(issue.project, issue)
|
2016-01-13 10:38:42 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I visit issue page "Community fix"' do
|
|
|
|
mr = MergeRequest.find_by(title: 'Community fix')
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_merge_request_path(mr.target_project, mr)
|
2016-01-13 10:38:42 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should not see any related merge requests' do
|
|
|
|
page.within '.issue-details' do
|
2016-04-12 09:55:54 -04:00
|
|
|
expect(page).not_to have_content('#merge-requests .merge-requests-title')
|
2016-01-13 10:38:42 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should see the "Enterprise fix" related merge request' do
|
2016-04-12 09:55:54 -04:00
|
|
|
page.within '#merge-requests .merge-requests-title' do
|
2016-01-13 10:38:42 -05:00
|
|
|
expect(page).to have_content('1 Related Merge Request')
|
2016-04-12 09:55:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
page.within '#merge-requests ul' do
|
2016-01-13 10:38:42 -05:00
|
|
|
expect(page).to have_content('Enterprise fix')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should see a note linking to "Enterprise fix" merge request' do
|
|
|
|
visible_note(
|
|
|
|
issuable: MergeRequest.find_by(title: 'Enterprise fix'),
|
|
|
|
from_project_name: 'Community',
|
|
|
|
user_name: 'Mary Jane'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should see a note linking to "Enterprise issue" issue' do
|
|
|
|
visible_note(
|
|
|
|
issuable: Issue.find_by(title: 'Enterprise issue'),
|
|
|
|
from_project_name: 'Community',
|
|
|
|
user_name: 'Mary Jane'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2014-10-17 00:10:50 -04:00
|
|
|
step 'I click link "Edit" for the merge request' do
|
|
|
|
edit_issuable
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I click link "Edit" for the issue' do
|
|
|
|
edit_issuable
|
|
|
|
end
|
2016-01-13 10:38:42 -05:00
|
|
|
|
2016-01-21 12:54:10 -05:00
|
|
|
step 'I sort the list by "Oldest updated"' do
|
2016-11-18 15:19:44 -05:00
|
|
|
find('button.dropdown-toggle').click
|
2016-05-16 13:36:27 -04:00
|
|
|
page.within('.content ul.dropdown-menu.dropdown-menu-align-right li') do
|
2016-01-21 12:54:10 -05:00
|
|
|
click_link "Oldest updated"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-02-17 08:32:02 -05:00
|
|
|
step 'I sort the list by "Least popular"' do
|
2016-11-18 15:19:44 -05:00
|
|
|
find('button.dropdown-toggle').click
|
2016-02-17 08:32:02 -05:00
|
|
|
|
2016-05-16 13:36:27 -04:00
|
|
|
page.within('.content ul.dropdown-menu.dropdown-menu-align-right li') do
|
2016-02-17 08:32:02 -05:00
|
|
|
click_link 'Least popular'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I sort the list by "Most popular"' do
|
2016-11-18 15:19:44 -05:00
|
|
|
find('button.dropdown-toggle').click
|
2016-02-17 08:32:02 -05:00
|
|
|
|
2016-05-16 13:36:27 -04:00
|
|
|
page.within('.content ul.dropdown-menu.dropdown-menu-align-right li') do
|
2016-02-17 08:32:02 -05:00
|
|
|
click_link 'Most popular'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-01-21 12:54:10 -05:00
|
|
|
step 'The list should be sorted by "Oldest updated"' do
|
2016-08-11 12:48:32 -04:00
|
|
|
expect(find('.issues-filters')).to have_content('Oldest updated')
|
2016-01-21 12:54:10 -05:00
|
|
|
end
|
|
|
|
|
2016-02-15 09:19:23 -05:00
|
|
|
step 'I click link "Next" in the sidebar' do
|
|
|
|
page.within '.issuable-sidebar' do
|
|
|
|
click_link 'Next'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-01-13 10:38:42 -05:00
|
|
|
def create_issuable_for_project(project_name:, title:, type: :issue)
|
|
|
|
project = Project.find_by(name: project_name)
|
|
|
|
|
|
|
|
attrs = {
|
|
|
|
title: title,
|
|
|
|
author: project.users.first,
|
|
|
|
description: '# Description header'
|
|
|
|
}
|
|
|
|
|
|
|
|
case type
|
|
|
|
when :issue
|
2017-02-21 18:50:22 -05:00
|
|
|
attrs[:project] = project
|
2016-01-13 10:38:42 -05:00
|
|
|
when :merge_request
|
|
|
|
attrs.merge!(
|
|
|
|
source_project: project,
|
|
|
|
target_project: project,
|
|
|
|
source_branch: 'fix',
|
|
|
|
target_branch: 'master'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
create(type, attrs)
|
|
|
|
end
|
|
|
|
|
|
|
|
def leave_reference_comment(issuable:, from_project_name:)
|
|
|
|
project = Project.find_by(name: from_project_name)
|
|
|
|
|
|
|
|
page.within('.js-main-target-form') do
|
|
|
|
fill_in 'note[note]', with: "##{issuable.to_reference(project)}"
|
2016-03-04 08:52:29 -05:00
|
|
|
click_button 'Comment'
|
2016-01-13 10:38:42 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def visible_note(issuable:, from_project_name:, user_name:)
|
|
|
|
project = Project.find_by(name: from_project_name)
|
|
|
|
|
|
|
|
expect(page).to have_content(user_name)
|
2016-11-23 01:55:23 -05:00
|
|
|
expect(page).to have_content("mentioned in #{issuable.class.to_s.titleize.downcase} #{issuable.to_reference(project)}")
|
2016-01-13 10:38:42 -05:00
|
|
|
end
|
|
|
|
|
2016-02-15 09:19:23 -05:00
|
|
|
def expect_sidebar_content(content)
|
|
|
|
page.within '.issuable-sidebar' do
|
|
|
|
expect(page).to have_content content
|
|
|
|
end
|
|
|
|
end
|
2014-10-17 00:10:50 -04:00
|
|
|
end
|