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