2016-06-16 23:09:34 +05:30
|
|
|
require 'rails_helper'
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe 'Merge request > User awards emoji', :js do
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project) { create(:project, :public, :repository) }
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:user) { project.creator }
|
|
|
|
let(:merge_request) { create(:merge_request, source_project: project, author: create(:user)) }
|
2018-12-23 12:14:25 +05:30
|
|
|
let!(:note) { create(:note, noteable: merge_request, project: merge_request.project) }
|
2016-06-16 23:09:34 +05:30
|
|
|
|
|
|
|
describe 'logged in' do
|
|
|
|
before do
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(user)
|
|
|
|
visit project_merge_request_path(project, merge_request)
|
2018-12-23 12:14:25 +05:30
|
|
|
|
|
|
|
wait_for_requests
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
it 'adds award to merge request' 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_merge_request_path(project, merge_request)
|
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 merge request' 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_merge_request_path(project, merge_request)
|
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 'has only 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
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2018-12-23 12:14:25 +05:30
|
|
|
it 'adds awards to note' do
|
|
|
|
first('.js-note-emoji').click
|
|
|
|
first('.emoji-menu .js-emoji-btn').click
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_selector('.js-awards-block')
|
|
|
|
end
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
describe 'the project is archived' do
|
|
|
|
let(:project) { create(:project, :public, :repository, :archived) }
|
|
|
|
|
|
|
|
it 'does not see award menu button' do
|
|
|
|
expect(page).not_to have_selector('.js-award-holder')
|
|
|
|
end
|
|
|
|
end
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
describe 'logged out' do
|
|
|
|
before do
|
2017-09-10 17:25:29 +05:30
|
|
|
visit project_merge_request_path(project, merge_request)
|
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
|