2016-02-20 08:59:59 -05:00
|
|
|
class Spinach::Features::DashboardTodos < Spinach::FeatureSteps
|
2016-02-15 17:26:30 -05:00
|
|
|
include SharedAuthentication
|
|
|
|
include SharedPaths
|
|
|
|
include SharedProject
|
|
|
|
include SharedUser
|
|
|
|
|
|
|
|
step '"John Doe" is a developer of project "Shop"' do
|
|
|
|
project.team << [john_doe, :developer]
|
|
|
|
end
|
|
|
|
|
2016-02-17 22:20:31 -05:00
|
|
|
step 'I am a developer of project "Enterprise"' do
|
|
|
|
enterprise.team << [current_user, :developer]
|
|
|
|
end
|
|
|
|
|
|
|
|
step '"Mary Jane" is a developer of project "Shop"' do
|
|
|
|
project.team << [john_doe, :developer]
|
|
|
|
end
|
|
|
|
|
2016-02-20 08:59:59 -05:00
|
|
|
step 'I have todos' do
|
|
|
|
create(:todo, user: current_user, project: project, author: mary_jane, target: issue, action: Todo::MENTIONED)
|
|
|
|
create(:todo, user: current_user, project: project, author: john_doe, target: issue, action: Todo::ASSIGNED)
|
2016-04-26 07:52:18 -04:00
|
|
|
note = create(:note, author: john_doe, noteable: issue, note: "#{current_user.to_reference} Wdyt?", project: project)
|
2016-02-20 08:59:59 -05:00
|
|
|
create(:todo, user: current_user, project: project, author: john_doe, target: issue, action: Todo::MENTIONED, note: note)
|
|
|
|
create(:todo, user: current_user, project: project, author: john_doe, target: merge_request, action: Todo::ASSIGNED)
|
2016-02-15 17:26:30 -05:00
|
|
|
end
|
|
|
|
|
2016-02-20 08:59:59 -05:00
|
|
|
step 'I should see todos assigned to me' do
|
2017-01-10 18:53:51 -05:00
|
|
|
merge_request_reference = merge_request.to_reference(full: true)
|
|
|
|
issue_reference = issue.to_reference(full: true)
|
|
|
|
|
2016-06-14 22:09:48 -04:00
|
|
|
page.within('.todos-pending-count') { expect(page).to have_content '4' }
|
2016-02-20 15:05:57 -05:00
|
|
|
expect(page).to have_content 'To do 4'
|
2016-02-17 22:20:31 -05:00
|
|
|
expect(page).to have_content 'Done 0'
|
|
|
|
|
|
|
|
expect(page).to have_link project.name_with_namespace
|
2017-01-10 18:53:51 -05:00
|
|
|
should_see_todo(1, "John Doe assigned you merge request #{merge_request_reference}", merge_request.title)
|
|
|
|
should_see_todo(2, "John Doe mentioned you on issue #{issue_reference}", "#{current_user.to_reference} Wdyt?")
|
|
|
|
should_see_todo(3, "John Doe assigned you issue #{issue_reference}", issue.title)
|
|
|
|
should_see_todo(4, "Mary Jane mentioned you on issue #{issue_reference}", issue.title)
|
2016-02-15 17:26:30 -05:00
|
|
|
end
|
|
|
|
|
2016-02-20 08:59:59 -05:00
|
|
|
step 'I mark the todo as done' do
|
|
|
|
page.within('.todo:nth-child(1)') do
|
2016-02-17 22:20:31 -05:00
|
|
|
click_link 'Done'
|
|
|
|
end
|
2016-02-15 17:26:30 -05:00
|
|
|
|
2016-06-14 22:09:48 -04:00
|
|
|
page.within('.todos-pending-count') { expect(page).to have_content '3' }
|
2016-02-20 15:05:57 -05:00
|
|
|
expect(page).to have_content 'To do 3'
|
2016-02-17 22:20:31 -05:00
|
|
|
expect(page).to have_content 'Done 1'
|
2017-01-10 18:53:51 -05:00
|
|
|
should_not_see_todo "John Doe assigned you merge request #{merge_request.to_reference(full: true)}"
|
2016-02-15 17:26:30 -05:00
|
|
|
end
|
|
|
|
|
2016-06-14 22:09:48 -04:00
|
|
|
step 'I mark all todos as done' do
|
2017-01-10 18:53:51 -05:00
|
|
|
merge_request_reference = merge_request.to_reference(full: true)
|
|
|
|
issue_reference = issue.to_reference(full: true)
|
|
|
|
|
2016-06-14 22:09:48 -04:00
|
|
|
click_link 'Mark all as done'
|
|
|
|
|
|
|
|
page.within('.todos-pending-count') { expect(page).to have_content '0' }
|
|
|
|
expect(page).to have_content 'To do 0'
|
|
|
|
expect(page).to have_content 'Done 4'
|
2016-08-30 15:20:31 -04:00
|
|
|
expect(page).to have_content "You're all done!"
|
2016-08-28 12:46:01 -04:00
|
|
|
expect('.prepend-top-default').not_to have_link project.name_with_namespace
|
2017-01-10 18:53:51 -05:00
|
|
|
should_not_see_todo "John Doe assigned you merge request #{merge_request_reference}"
|
|
|
|
should_not_see_todo "John Doe mentioned you on issue #{issue_reference}"
|
|
|
|
should_not_see_todo "John Doe assigned you issue #{issue_reference}"
|
|
|
|
should_not_see_todo "Mary Jane mentioned you on issue #{issue_reference}"
|
2016-06-14 22:09:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should see the todo marked as done' do
|
2016-02-17 22:20:31 -05:00
|
|
|
click_link 'Done 1'
|
2016-06-14 22:09:48 -04:00
|
|
|
|
|
|
|
expect(page).to have_link project.name_with_namespace
|
2017-01-10 18:53:51 -05:00
|
|
|
should_see_todo(1, "John Doe assigned you merge request #{merge_request.to_reference(full: true)}", merge_request.title, false)
|
2016-02-15 17:26:30 -05:00
|
|
|
end
|
|
|
|
|
2016-02-20 08:59:59 -05:00
|
|
|
step 'I should see all todos marked as done' do
|
2017-01-10 18:53:51 -05:00
|
|
|
merge_request_reference = merge_request.to_reference(full: true)
|
|
|
|
issue_reference = issue.to_reference(full: true)
|
|
|
|
|
2016-06-14 22:09:48 -04:00
|
|
|
click_link 'Done 4'
|
|
|
|
|
2016-02-17 22:20:31 -05:00
|
|
|
expect(page).to have_link project.name_with_namespace
|
2017-01-10 18:53:51 -05:00
|
|
|
should_see_todo(1, "John Doe assigned you merge request #{merge_request_reference}", merge_request.title, false)
|
|
|
|
should_see_todo(2, "John Doe mentioned you on issue #{issue_reference}", "#{current_user.to_reference} Wdyt?", false)
|
|
|
|
should_see_todo(3, "John Doe assigned you issue #{issue_reference}", issue.title, false)
|
|
|
|
should_see_todo(4, "Mary Jane mentioned you on issue #{issue_reference}", issue.title, false)
|
2016-02-17 22:20:31 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I filter by "Enterprise"' do
|
2016-08-28 12:46:01 -04:00
|
|
|
click_button 'Project'
|
|
|
|
page.within '.dropdown-menu-project' do
|
|
|
|
click_link enterprise.name_with_namespace
|
|
|
|
end
|
2016-02-17 22:20:31 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I filter by "John Doe"' do
|
2016-08-28 12:46:01 -04:00
|
|
|
click_button 'Author'
|
|
|
|
page.within '.dropdown-menu-author' do
|
|
|
|
click_link john_doe.username
|
|
|
|
end
|
2016-02-17 22:20:31 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I filter by "Issue"' do
|
2016-08-28 12:46:01 -04:00
|
|
|
click_button 'Type'
|
|
|
|
page.within '.dropdown-menu-type' do
|
|
|
|
click_link 'Issue'
|
|
|
|
end
|
2016-02-17 22:20:31 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I filter by "Mentioned"' do
|
2016-08-28 12:46:01 -04:00
|
|
|
click_button 'Action'
|
|
|
|
page.within '.dropdown-menu-action' do
|
|
|
|
click_link 'Mentioned'
|
|
|
|
end
|
2016-02-17 22:20:31 -05:00
|
|
|
end
|
|
|
|
|
2016-02-20 08:59:59 -05:00
|
|
|
step 'I should not see todos' do
|
2016-02-20 15:05:57 -05:00
|
|
|
expect(page).to have_content "You're all done!"
|
2016-02-17 22:20:31 -05:00
|
|
|
end
|
|
|
|
|
2016-02-20 08:59:59 -05:00
|
|
|
step 'I should not see todos related to "Mary Jane" in the list' do
|
2017-01-10 18:53:51 -05:00
|
|
|
should_not_see_todo "Mary Jane mentioned you on issue #{issue.to_reference(full: true)}"
|
2016-02-17 22:20:31 -05:00
|
|
|
end
|
|
|
|
|
2016-02-20 08:59:59 -05:00
|
|
|
step 'I should not see todos related to "Merge Requests" in the list' do
|
2017-01-10 18:53:51 -05:00
|
|
|
should_not_see_todo "John Doe assigned you merge request #{merge_request.to_reference(full: true)}"
|
2016-02-17 22:20:31 -05:00
|
|
|
end
|
|
|
|
|
2016-02-20 08:59:59 -05:00
|
|
|
step 'I should not see todos related to "Assignments" in the list' do
|
2017-01-10 18:53:51 -05:00
|
|
|
should_not_see_todo "John Doe assigned you merge request #{merge_request.to_reference(full: true)}"
|
|
|
|
should_not_see_todo "John Doe assigned you issue #{issue.to_reference(full: true)}"
|
2016-02-17 22:20:31 -05:00
|
|
|
end
|
|
|
|
|
2016-03-30 10:17:03 -04:00
|
|
|
step 'I click on the todo' do
|
2016-03-30 13:28:36 -04:00
|
|
|
find('.todo:nth-child(1)').click
|
2016-03-30 10:17:03 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should be directed to the corresponding page' do
|
|
|
|
page.should have_css('.identifier', text: 'Merge Request !1')
|
|
|
|
end
|
|
|
|
|
2016-02-20 08:59:59 -05:00
|
|
|
def should_see_todo(position, title, body, pending = true)
|
|
|
|
page.within(".todo:nth-child(#{position})") do
|
2016-02-17 22:20:31 -05:00
|
|
|
expect(page).to have_content title
|
|
|
|
expect(page).to have_content body
|
|
|
|
|
|
|
|
if pending
|
|
|
|
expect(page).to have_link 'Done'
|
|
|
|
else
|
2016-05-23 19:37:59 -04:00
|
|
|
expect(page).not_to have_link 'Done'
|
2016-02-17 22:20:31 -05:00
|
|
|
end
|
2016-02-15 17:26:30 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-02-20 08:59:59 -05:00
|
|
|
def should_not_see_todo(title)
|
2016-02-17 22:20:31 -05:00
|
|
|
expect(page).not_to have_content title
|
2016-02-15 17:26:30 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def john_doe
|
|
|
|
@john_doe ||= user_exists("John Doe", { username: "john_doe" })
|
|
|
|
end
|
|
|
|
|
2016-02-17 22:20:31 -05:00
|
|
|
def mary_jane
|
|
|
|
@mary_jane ||= user_exists("Mary Jane", { username: "mary_jane" })
|
|
|
|
end
|
|
|
|
|
|
|
|
def enterprise
|
|
|
|
@enterprise ||= Project.find_by(name: 'Enterprise')
|
|
|
|
end
|
|
|
|
|
|
|
|
def issue
|
|
|
|
@issue ||= create(:issue, assignee: current_user, project: project)
|
|
|
|
end
|
|
|
|
|
|
|
|
def merge_request
|
|
|
|
@merge_request ||= create(:merge_request, assignee: current_user, source_project: project)
|
2016-02-15 17:26:30 -05:00
|
|
|
end
|
|
|
|
end
|