2016-04-01 16:25:28 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
feature 'Issue awards', :js do
|
2016-04-01 16:25:28 +00:00
|
|
|
let(:user) { create(:user) }
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project, :public) }
|
2016-04-01 16:25:28 +00:00
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
|
|
|
|
describe 'logged in' do
|
|
|
|
before do
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_issue_path(project, issue)
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2016-04-01 16:25:28 +00:00
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'adds award to issue' do
|
2016-04-01 16:25:28 +00:00
|
|
|
first('.js-emoji-btn').click
|
|
|
|
expect(page).to have_selector('.js-emoji-btn.active')
|
|
|
|
expect(first('.js-emoji-btn')).to have_content '1'
|
2016-06-01 09:23:09 +00:00
|
|
|
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_issue_path(project, issue)
|
2016-06-01 09:23:09 +00:00
|
|
|
expect(first('.js-emoji-btn')).to have_content '1'
|
2016-04-01 16:25:28 +00:00
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'removes award from issue' do
|
2016-04-01 16:25:28 +00:00
|
|
|
first('.js-emoji-btn').click
|
|
|
|
find('.js-emoji-btn.active').click
|
|
|
|
expect(first('.js-emoji-btn')).to have_content '0'
|
2016-06-01 09:23:09 +00:00
|
|
|
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_issue_path(project, issue)
|
2016-06-01 09:23:09 +00:00
|
|
|
expect(first('.js-emoji-btn')).to have_content '0'
|
2016-04-01 16:25:28 +00:00
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'only has one menu on the page' do
|
2016-04-01 16:25:28 +00:00
|
|
|
first('.js-add-award').click
|
|
|
|
expect(page).to have_selector('.emoji-menu')
|
|
|
|
|
2016-04-01 17:18:45 +00:00
|
|
|
expect(page).to have_selector('.emoji-menu', count: 1)
|
2016-04-01 16:25:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'logged out' do
|
|
|
|
before do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_issue_path(project, issue)
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2016-04-01 16:25:28 +00:00
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'does not see award menu button' do
|
2016-04-01 16:25:28 +00:00
|
|
|
expect(page).not_to have_selector('.js-award-holder')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|