2016-10-04 11:53:39 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
describe 'Issue Boards new issue', :js do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project, :public) }
|
2016-10-06 20:14:39 +00:00
|
|
|
let(:board) { create(:board, project: project) }
|
2017-01-27 05:28:06 +00:00
|
|
|
let!(:list) { create(:list, board: board, position: 0) }
|
2016-10-04 11:53:39 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
context 'authorized user' do
|
|
|
|
before do
|
2017-12-22 08:18:28 +00:00
|
|
|
project.add_master(user)
|
2016-10-04 11:53:39 +00:00
|
|
|
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2016-10-04 11:53:39 +00:00
|
|
|
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_board_path(project, board)
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2016-10-04 11:53:39 +00:00
|
|
|
|
2017-06-01 09:15:09 +00:00
|
|
|
expect(page).to have_selector('.board', count: 3)
|
2016-10-04 11:53:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays new issue button' do
|
2017-06-13 23:04:15 +00:00
|
|
|
expect(first('.board')).to have_selector('.issue-count-badge-add-button', count: 1)
|
2016-10-04 11:53:39 +00:00
|
|
|
end
|
|
|
|
|
2017-03-24 12:40:35 +00:00
|
|
|
it 'does not display new issue button in closed list' do
|
2017-06-01 09:15:09 +00:00
|
|
|
page.within('.board:nth-child(3)') do
|
2017-06-13 23:04:15 +00:00
|
|
|
expect(page).not_to have_selector('.issue-count-badge-add-button')
|
2016-10-04 11:53:39 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows form when clicking button' do
|
|
|
|
page.within(first('.board')) do
|
2017-06-13 23:04:15 +00:00
|
|
|
find('.issue-count-badge-add-button').click
|
2016-10-04 11:53:39 +00:00
|
|
|
|
|
|
|
expect(page).to have_selector('.board-new-issue-form')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'hides form when clicking cancel' do
|
|
|
|
page.within(first('.board')) do
|
2017-06-13 23:04:15 +00:00
|
|
|
find('.issue-count-badge-add-button').click
|
2016-10-04 11:53:39 +00:00
|
|
|
|
|
|
|
expect(page).to have_selector('.board-new-issue-form')
|
|
|
|
|
|
|
|
click_button 'Cancel'
|
|
|
|
|
2016-11-09 09:17:14 +00:00
|
|
|
expect(page).not_to have_selector('.board-new-issue-form')
|
2016-10-04 11:53:39 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates new issue' do
|
|
|
|
page.within(first('.board')) do
|
2017-06-13 23:04:15 +00:00
|
|
|
find('.issue-count-badge-add-button').click
|
2016-10-04 11:53:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
page.within(first('.board-new-issue-form')) do
|
|
|
|
find('.form-control').set('bug')
|
|
|
|
click_button 'Submit issue'
|
|
|
|
end
|
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2016-10-04 11:53:39 +00:00
|
|
|
|
2017-06-13 23:04:15 +00:00
|
|
|
page.within(first('.board .issue-count-badge-count')) do
|
2016-10-04 11:53:39 +00:00
|
|
|
expect(page).to have_content('1')
|
|
|
|
end
|
|
|
|
end
|
2016-10-07 08:55:12 +00:00
|
|
|
|
|
|
|
it 'shows sidebar when creating new issue' do
|
|
|
|
page.within(first('.board')) do
|
2017-06-13 23:04:15 +00:00
|
|
|
find('.issue-count-badge-add-button').click
|
2016-10-07 08:55:12 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
page.within(first('.board-new-issue-form')) do
|
|
|
|
find('.form-control').set('bug')
|
|
|
|
click_button 'Submit issue'
|
|
|
|
end
|
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2016-10-07 08:55:12 +00:00
|
|
|
|
|
|
|
expect(page).to have_selector('.issue-boards-sidebar')
|
|
|
|
end
|
2016-10-04 11:53:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'unauthorized user' do
|
|
|
|
before do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_board_path(project, board)
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2016-10-04 11:53:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not display new issue button' do
|
2017-06-13 23:04:15 +00:00
|
|
|
expect(page).to have_selector('.issue-count-badge-add-button', count: 0)
|
2016-10-04 11:53:39 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|