2016-04-01 12:25:28 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
feature 'Issue awards', js: true, feature: true do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
|
|
|
|
describe 'logged in' do
|
|
|
|
before do
|
|
|
|
login_as(user)
|
|
|
|
visit namespace_project_issue_path(project.namespace, project, issue)
|
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'adds award to issue' do
|
2016-04-01 12:25:28 -04: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 05:23:09 -04:00
|
|
|
|
|
|
|
visit namespace_project_issue_path(project.namespace, project, issue)
|
|
|
|
expect(first('.js-emoji-btn')).to have_content '1'
|
2016-04-01 12:25:28 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'removes award from issue' do
|
2016-04-01 12:25:28 -04:00
|
|
|
first('.js-emoji-btn').click
|
|
|
|
find('.js-emoji-btn.active').click
|
|
|
|
expect(first('.js-emoji-btn')).to have_content '0'
|
2016-06-01 05:23:09 -04:00
|
|
|
|
|
|
|
visit namespace_project_issue_path(project.namespace, project, issue)
|
|
|
|
expect(first('.js-emoji-btn')).to have_content '0'
|
2016-04-01 12:25:28 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'only has one menu on the page' do
|
2016-04-01 12:25:28 -04:00
|
|
|
first('.js-add-award').click
|
|
|
|
expect(page).to have_selector('.emoji-menu')
|
|
|
|
|
2016-04-01 13:18:45 -04:00
|
|
|
expect(page).to have_selector('.emoji-menu', count: 1)
|
2016-04-01 12:25:28 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'logged out' do
|
|
|
|
before do
|
|
|
|
visit namespace_project_issue_path(project.namespace, project, issue)
|
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'does not see award menu button' do
|
2016-04-01 12:25:28 -04:00
|
|
|
expect(page).not_to have_selector('.js-award-holder')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|