1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Merge request > User assigns themselves' do
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
it 'updates related issues', :js do
click_link 'Assign yourself to these issues'
expect(page).to have_content '2 issues have been assigned to you'
end
it 'updates updated_by', :js do
expect { click_button 'assign yourself' }.to change { merge_request.reload.updated_at }
end
it 'returns user to the merge request', :js do
click_link 'Assign yourself to these issues'
expect(page).to have_content merge_request.description
end
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
it 'does not show assignment link' do
expect(page).not_to have_content 'Assign yourself'
end
end
end
|