2015-05-04 23:06:57 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-06-26 09:05:30 -04:00
|
|
|
feature 'Task Lists', feature: true do
|
2015-05-04 23:06:57 -04:00
|
|
|
include Warden::Test::Helpers
|
|
|
|
|
2017-03-28 17:13:16 -04:00
|
|
|
let(:project) { create(:empty_project) }
|
2015-05-04 23:06:57 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:user2) { create(:user) }
|
|
|
|
|
|
|
|
let(:markdown) do
|
|
|
|
<<-MARKDOWN.strip_heredoc
|
|
|
|
This is a task list:
|
|
|
|
|
|
|
|
- [ ] Incomplete entry 1
|
|
|
|
- [x] Complete entry 1
|
|
|
|
- [ ] Incomplete entry 2
|
|
|
|
- [x] Complete entry 2
|
|
|
|
- [ ] Incomplete entry 3
|
|
|
|
- [ ] Incomplete entry 4
|
|
|
|
MARKDOWN
|
|
|
|
end
|
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
let(:singleIncompleteMarkdown) do
|
|
|
|
<<-MARKDOWN.strip_heredoc
|
|
|
|
This is a task list:
|
|
|
|
|
|
|
|
- [ ] Incomplete entry 1
|
|
|
|
MARKDOWN
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:singleCompleteMarkdown) do
|
|
|
|
<<-MARKDOWN.strip_heredoc
|
|
|
|
This is a task list:
|
|
|
|
|
|
|
|
- [x] Incomplete entry 1
|
|
|
|
MARKDOWN
|
|
|
|
end
|
|
|
|
|
2017-01-18 08:33:13 -05:00
|
|
|
let(:nested_tasks_markdown) do
|
|
|
|
<<-EOT.strip_heredoc
|
|
|
|
- [ ] Task a
|
|
|
|
- [x] Task a.1
|
|
|
|
- [ ] Task a.2
|
|
|
|
- [ ] Task b
|
|
|
|
|
|
|
|
1. [ ] Task 1
|
|
|
|
1. [ ] Task 1.1
|
|
|
|
1. [x] Task 1.2
|
|
|
|
EOT
|
|
|
|
end
|
|
|
|
|
2015-05-04 23:06:57 -04:00
|
|
|
before do
|
|
|
|
Warden.test_mode!
|
|
|
|
|
|
|
|
project.team << [user, :master]
|
|
|
|
project.team << [user2, :guest]
|
|
|
|
|
|
|
|
login_as(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
def visit_issue(project, issue)
|
|
|
|
visit namespace_project_issue_path(project.namespace, project, issue)
|
|
|
|
end
|
|
|
|
|
2017-05-01 22:59:52 -04:00
|
|
|
describe 'for Issues', feature: true do
|
2017-04-24 17:03:58 -04:00
|
|
|
describe 'multiple tasks', js: true do
|
2016-08-27 13:36:08 -04:00
|
|
|
let!(:issue) { create(:issue, description: markdown, author: user, project: project) }
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
it 'renders' do
|
|
|
|
visit_issue(project, issue)
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-04-24 17:03:58 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
expect(page).to have_selector('ul.task-list', count: 1)
|
|
|
|
expect(page).to have_selector('li.task-list-item', count: 6)
|
|
|
|
expect(page).to have_selector('ul input[checked]', count: 2)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains the required selectors' do
|
|
|
|
visit_issue(project, issue)
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-08-27 13:36:08 -04:00
|
|
|
|
2017-05-03 16:35:54 -04:00
|
|
|
expect(page).to have_selector(".wiki .task-list .task-list-item .task-list-item-checkbox")
|
2016-08-27 13:36:08 -04:00
|
|
|
expect(page).to have_selector('a.btn-close')
|
|
|
|
end
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
it 'is only editable by author' do
|
|
|
|
visit_issue(project, issue)
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-04-24 17:03:58 -04:00
|
|
|
|
2017-05-03 16:35:54 -04:00
|
|
|
expect(page).to have_selector(".wiki .task-list .task-list-item .task-list-item-checkbox")
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
logout(:user)
|
|
|
|
login_as(user2)
|
|
|
|
visit current_path
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-05-03 16:35:54 -04:00
|
|
|
|
|
|
|
expect(page).to have_selector(".wiki .task-list .task-list-item .task-list-item-checkbox")
|
2016-08-27 13:36:08 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'provides a summary on Issues#index' do
|
|
|
|
visit namespace_project_issues_path(project.namespace, project)
|
|
|
|
expect(page).to have_content("2 of 6 tasks completed")
|
|
|
|
end
|
2015-05-04 23:06:57 -04:00
|
|
|
end
|
|
|
|
|
2017-05-01 22:56:04 -04:00
|
|
|
describe 'single incomplete task', js: true do
|
2016-08-27 13:36:08 -04:00
|
|
|
let!(:issue) { create(:issue, description: singleIncompleteMarkdown, author: user, project: project) }
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
it 'renders' do
|
|
|
|
visit_issue(project, issue)
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-04-24 17:03:58 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
expect(page).to have_selector('ul.task-list', count: 1)
|
|
|
|
expect(page).to have_selector('li.task-list-item', count: 1)
|
|
|
|
expect(page).to have_selector('ul input[checked]', count: 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'provides a summary on Issues#index' do
|
|
|
|
visit namespace_project_issues_path(project.namespace, project)
|
2017-05-03 16:35:54 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
expect(page).to have_content("0 of 1 task completed")
|
|
|
|
end
|
2015-05-04 23:06:57 -04:00
|
|
|
end
|
|
|
|
|
2017-05-03 16:35:54 -04:00
|
|
|
describe 'single complete task', js: true do
|
2016-08-27 13:36:08 -04:00
|
|
|
let!(:issue) { create(:issue, description: singleCompleteMarkdown, author: user, project: project) }
|
|
|
|
|
|
|
|
it 'renders' do
|
|
|
|
visit_issue(project, issue)
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-04-24 17:03:58 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
expect(page).to have_selector('ul.task-list', count: 1)
|
|
|
|
expect(page).to have_selector('li.task-list-item', count: 1)
|
|
|
|
expect(page).to have_selector('ul input[checked]', count: 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'provides a summary on Issues#index' do
|
|
|
|
visit namespace_project_issues_path(project.namespace, project)
|
2017-05-03 16:35:54 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
expect(page).to have_content("1 of 1 task completed")
|
|
|
|
end
|
2015-05-04 23:06:57 -04:00
|
|
|
end
|
2017-01-18 08:33:13 -05:00
|
|
|
|
|
|
|
describe 'nested tasks', js: true do
|
|
|
|
let(:issue) { create(:issue, description: nested_tasks_markdown, author: user, project: project) }
|
|
|
|
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
visit_issue(project, issue)
|
|
|
|
end
|
2017-01-18 08:33:13 -05:00
|
|
|
|
|
|
|
it 'renders' do
|
|
|
|
expect(page).to have_selector('ul.task-list', count: 2)
|
|
|
|
expect(page).to have_selector('li.task-list-item', count: 7)
|
|
|
|
expect(page).to have_selector('ul input[checked]', count: 1)
|
|
|
|
expect(page).to have_selector('ol input[checked]', count: 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'solves tasks' do
|
|
|
|
expect(page).to have_content("2 of 7 tasks completed")
|
|
|
|
|
|
|
|
page.find('li.task-list-item', text: 'Task b').find('input').click
|
|
|
|
page.find('li.task-list-item ul li.task-list-item', text: 'Task a.2').find('input').click
|
|
|
|
page.find('li.task-list-item ol li.task-list-item', text: 'Task 1.1').find('input').click
|
|
|
|
|
|
|
|
expect(page).to have_content("5 of 7 tasks completed")
|
|
|
|
|
|
|
|
visit_issue(project, issue) # reload to see new system notes
|
|
|
|
|
|
|
|
expect(page).to have_content('marked the task Task b as complete')
|
|
|
|
expect(page).to have_content('marked the task Task a.2 as complete')
|
|
|
|
expect(page).to have_content('marked the task Task 1.1 as complete')
|
|
|
|
end
|
|
|
|
end
|
2015-05-04 23:06:57 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'for Notes' do
|
|
|
|
let!(:issue) { create(:issue, author: user, project: project) }
|
2016-08-27 13:36:08 -04:00
|
|
|
describe 'multiple tasks' do
|
|
|
|
let!(:note) do
|
|
|
|
create(:note, note: markdown, noteable: issue,
|
|
|
|
project: project, author: user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders for note body' do
|
|
|
|
visit_issue(project, issue)
|
|
|
|
|
|
|
|
expect(page).to have_selector('.note ul.task-list', count: 1)
|
|
|
|
expect(page).to have_selector('.note li.task-list-item', count: 6)
|
|
|
|
expect(page).to have_selector('.note ul input[checked]', count: 2)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains the required selectors' do
|
|
|
|
visit_issue(project, issue)
|
|
|
|
|
|
|
|
expect(page).to have_selector('.note .js-task-list-container')
|
|
|
|
expect(page).to have_selector('.note .js-task-list-container .task-list .task-list-item .task-list-item-checkbox')
|
|
|
|
expect(page).to have_selector('.note .js-task-list-container .js-task-list-field')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is only editable by author' do
|
|
|
|
visit_issue(project, issue)
|
|
|
|
expect(page).to have_selector('.js-task-list-container')
|
|
|
|
|
|
|
|
logout(:user)
|
|
|
|
|
|
|
|
login_as(user2)
|
|
|
|
visit current_path
|
|
|
|
expect(page).not_to have_selector('.js-task-list-container')
|
|
|
|
end
|
2016-04-26 07:52:18 -04:00
|
|
|
end
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
describe 'single incomplete task' do
|
|
|
|
let!(:note) do
|
|
|
|
create(:note, note: singleIncompleteMarkdown, noteable: issue,
|
|
|
|
project: project, author: user)
|
|
|
|
end
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
it 'renders for note body' do
|
|
|
|
visit_issue(project, issue)
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
expect(page).to have_selector('.note ul.task-list', count: 1)
|
|
|
|
expect(page).to have_selector('.note li.task-list-item', count: 1)
|
|
|
|
expect(page).to have_selector('.note ul input[checked]', count: 0)
|
|
|
|
end
|
2015-05-04 23:06:57 -04:00
|
|
|
end
|
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
describe 'single complete task' do
|
|
|
|
let!(:note) do
|
|
|
|
create(:note, note: singleCompleteMarkdown, noteable: issue,
|
|
|
|
project: project, author: user)
|
|
|
|
end
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
it 'renders for note body' do
|
|
|
|
visit_issue(project, issue)
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
expect(page).to have_selector('.note ul.task-list', count: 1)
|
|
|
|
expect(page).to have_selector('.note li.task-list-item', count: 1)
|
|
|
|
expect(page).to have_selector('.note ul input[checked]', count: 1)
|
|
|
|
end
|
2015-05-04 23:06:57 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'for Merge Requests' do
|
|
|
|
def visit_merge_request(project, merge)
|
|
|
|
visit namespace_project_merge_request_path(project.namespace, project, merge)
|
|
|
|
end
|
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
describe 'multiple tasks' do
|
2017-03-28 17:13:16 -04:00
|
|
|
let(:project) { create(:project, :repository) }
|
2016-08-27 13:36:08 -04:00
|
|
|
let!(:merge) { create(:merge_request, :simple, description: markdown, author: user, source_project: project) }
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
it 'renders for description' do
|
|
|
|
visit_merge_request(project, merge)
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
expect(page).to have_selector('ul.task-list', count: 1)
|
|
|
|
expect(page).to have_selector('li.task-list-item', count: 6)
|
|
|
|
expect(page).to have_selector('ul input[checked]', count: 2)
|
|
|
|
end
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
it 'contains the required selectors' do
|
|
|
|
visit_merge_request(project, merge)
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
container = '.detail-page-description .description.js-task-list-container'
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
expect(page).to have_selector(container)
|
|
|
|
expect(page).to have_selector("#{container} .wiki .task-list .task-list-item .task-list-item-checkbox")
|
|
|
|
expect(page).to have_selector("#{container} .js-task-list-field")
|
|
|
|
expect(page).to have_selector('form.js-issuable-update')
|
|
|
|
expect(page).to have_selector('a.btn-close')
|
|
|
|
end
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
it 'is only editable by author' do
|
|
|
|
visit_merge_request(project, merge)
|
|
|
|
expect(page).to have_selector('.js-task-list-container')
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
logout(:user)
|
2015-05-04 23:06:57 -04:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
login_as(user2)
|
|
|
|
visit current_path
|
|
|
|
expect(page).not_to have_selector('.js-task-list-container')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'provides a summary on MergeRequests#index' do
|
|
|
|
visit namespace_project_merge_requests_path(project.namespace, project)
|
|
|
|
expect(page).to have_content("2 of 6 tasks completed")
|
|
|
|
end
|
|
|
|
end
|
2017-01-18 08:33:13 -05:00
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
describe 'single incomplete task' do
|
|
|
|
let!(:merge) { create(:merge_request, :simple, description: singleIncompleteMarkdown, author: user, source_project: project) }
|
|
|
|
|
|
|
|
it 'renders for description' do
|
|
|
|
visit_merge_request(project, merge)
|
|
|
|
|
|
|
|
expect(page).to have_selector('ul.task-list', count: 1)
|
|
|
|
expect(page).to have_selector('li.task-list-item', count: 1)
|
|
|
|
expect(page).to have_selector('ul input[checked]', count: 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'provides a summary on MergeRequests#index' do
|
|
|
|
visit namespace_project_merge_requests_path(project.namespace, project)
|
|
|
|
expect(page).to have_content("0 of 1 task completed")
|
|
|
|
end
|
2015-05-04 23:06:57 -04:00
|
|
|
end
|
|
|
|
|
2016-08-27 13:36:08 -04:00
|
|
|
describe 'single complete task' do
|
|
|
|
let!(:merge) { create(:merge_request, :simple, description: singleCompleteMarkdown, author: user, source_project: project) }
|
|
|
|
|
|
|
|
it 'renders for description' do
|
|
|
|
visit_merge_request(project, merge)
|
|
|
|
|
|
|
|
expect(page).to have_selector('ul.task-list', count: 1)
|
|
|
|
expect(page).to have_selector('li.task-list-item', count: 1)
|
|
|
|
expect(page).to have_selector('ul input[checked]', count: 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'provides a summary on MergeRequests#index' do
|
|
|
|
visit namespace_project_merge_requests_path(project.namespace, project)
|
|
|
|
expect(page).to have_content("1 of 1 task completed")
|
|
|
|
end
|
2015-05-04 23:06:57 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|