2019-07-25 01:24:42 -04:00
# frozen_string_literal: true
2019-08-29 03:56:52 -04:00
require 'spec_helper'
2017-08-01 14:03:07 -04:00
2020-06-16 14:09:01 -04:00
RSpec . describe 'Merge request > User assigns themselves' do
2017-08-01 14:03:07 -04:00
let ( :project ) { create ( :project , :public , :repository ) }
let ( :user ) { project . creator }
let ( :issue1 ) { create ( :issue , project : project ) }
let ( :issue2 ) { create ( :issue , project : project ) }
let ( :merge_request ) { create ( :merge_request , :simple , source_project : project , author : user , description : " fixes #{ issue1 . to_reference } and #{ issue2 . to_reference } " ) }
context 'logged in as a member of the project' do
before do
sign_in ( user )
visit project_merge_request_path ( project , merge_request )
end
2021-11-02 11:12:22 -04:00
it 'updates related issues' , :js , quarantine : 'https://gitlab.com/gitlab-org/gitlab/-/issues/343006' do
2017-08-01 14:03:07 -04:00
click_link 'Assign yourself to these issues'
expect ( page ) . to have_content '2 issues have been assigned to you'
end
2020-09-04 20:08:43 -04:00
it 'updates updated_by' , :js do
2020-09-07 05:08:17 -04:00
expect do
click_button 'assign yourself'
expect ( find ( '.assignee' ) ) . to have_content ( user . name )
wait_for_all_requests
end . to change { merge_request . reload . updated_at }
2020-09-04 20:08:43 -04:00
end
2017-08-01 14:03:07 -04:00
context 'when related issues are already assigned' do
before do
[ issue1 , issue2 ] . each { | issue | issue . update! ( assignees : [ user ] ) }
end
it 'does not display if related issues are already assigned' do
expect ( page ) . not_to have_content 'Assign yourself'
end
end
end
context 'logged in as a non-member of the project' do
before do
sign_in ( create ( :user ) )
visit project_merge_request_path ( project , merge_request )
end
2018-11-19 09:08:23 -05:00
it 'does not show assignment link' do
2017-08-01 14:03:07 -04:00
expect ( page ) . not_to have_content 'Assign yourself'
end
end
end