2017-08-01 14:03:07 -04:00
|
|
|
require 'rails_helper'
|
2017-09-07 11:53:52 -04:00
|
|
|
|
2017-08-01 14:03:07 -04:00
|
|
|
describe 'Merge request > User locks discussion', :js do
|
2017-09-07 11:53:52 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :public, :repository) }
|
2017-08-01 14:03:07 -04:00
|
|
|
let(:merge_request) { create(:merge_request, source_project: project) }
|
2017-09-07 11:53:52 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the discussion is locked' do
|
|
|
|
before do
|
|
|
|
merge_request.update_attribute(:discussion_locked, true)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a user is a team member' do
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
visit project_merge_request_path(project, merge_request)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'the user can create a comment' do
|
|
|
|
page.within('.issuable-discussion #notes .js-main-target-form') do
|
|
|
|
fill_in 'note[note]', with: 'Some new comment'
|
|
|
|
click_button 'Comment'
|
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(find('.issuable-discussion #notes')).to have_content('Some new comment')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a user is not a team member' do
|
|
|
|
before do
|
|
|
|
visit project_merge_request_path(project, merge_request)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'the user can not create a comment' do
|
2018-06-21 08:22:40 -04:00
|
|
|
page.within('.js-vue-notes-event') do
|
2017-09-07 11:53:52 -04:00
|
|
|
expect(page).not_to have_selector('js-main-target-form')
|
2018-06-21 08:22:40 -04:00
|
|
|
expect(page.find('.issuable-note-warning'))
|
2017-09-27 02:30:40 -04:00
|
|
|
.to have_content('This merge request is locked. Only project members can comment.')
|
2017-09-07 11:53:52 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|