2016-08-08 18:30:01 -04:00
require 'rails_helper'
2017-10-03 04:35:01 -04:00
feature 'Merge request issue assignment' , :js do
2016-08-08 18:30:01 -04:00
let ( :user ) { create ( :user ) }
2017-07-26 17:52:10 -04:00
let ( :project ) { create ( :project , :public , :repository ) }
2016-08-08 18:30:01 -04:00
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 } " ) }
let ( :service ) { MergeRequests :: AssignIssuesService . new ( merge_request , user , user , project ) }
before do
project . team << [ user , :developer ]
end
def visit_merge_request ( current_user = nil )
2017-06-21 19:44:10 -04:00
sign_in ( current_user || user )
2017-07-06 12:20:50 -04:00
visit project_merge_request_path ( project , merge_request )
2016-08-08 18:30:01 -04:00
end
context 'logged in as author' do
2017-05-09 00:15:34 -04:00
it 'updates related issues' do
2016-08-08 18:30:01 -04:00
visit_merge_request
click_link " Assign yourself to these issues "
expect ( page ) . to have_content " 2 issues have been assigned to you "
end
it 'returns user to the merge request' do
visit_merge_request
click_link " Assign yourself to these issues "
expect ( page ) . to have_content merge_request . description
end
it " doesn't display if related issues are already assigned " do
2017-05-04 08:11:15 -04:00
[ issue1 , issue2 ] . each { | issue | issue . update! ( assignees : [ user ] ) }
2016-08-08 18:30:01 -04:00
visit_merge_request
expect ( page ) . not_to have_content " Assign yourself "
end
end
context 'not MR author' do
it " doesn't not show assignment link " do
visit_merge_request ( create ( :user ) )
expect ( page ) . not_to have_content " Assign yourself "
end
end
end