2016-04-01 12:35:10 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
feature 'Merge request awards', :js do
|
2016-04-01 12:35:10 -04:00
|
|
|
let(:user) { create(:user) }
|
2017-07-26 17:52:10 -04:00
|
|
|
let(:project) { create(:project, :public, :repository) }
|
2016-06-01 05:23:09 -04:00
|
|
|
let(:merge_request) { create(:merge_request, source_project: project) }
|
2016-04-01 12:35:10 -04:00
|
|
|
|
|
|
|
describe 'logged in' do
|
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2016-04-01 12:35:10 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'adds award to merge request' do
|
2016-04-01 12:35:10 -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
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2016-06-01 05:23:09 -04:00
|
|
|
expect(first('.js-emoji-btn')).to have_content '1'
|
2016-04-01 12:35:10 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'removes award from merge request' do
|
2016-04-01 12:35:10 -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
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2016-06-01 05:23:09 -04:00
|
|
|
expect(first('.js-emoji-btn')).to have_content '0'
|
2016-04-01 12:35:10 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'has only one menu on the page' do
|
2016-04-01 12:35:10 -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:35:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'logged out' do
|
|
|
|
before do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2016-04-01 12:35:10 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'does not see award menu button' do
|
2016-04-01 12:35:10 -04:00
|
|
|
expect(page).not_to have_selector('.js-award-holder')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|