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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# frozen_string_literal: true
require 'spec_helper'
describe 'Merge request > User resolves outdated diff discussions', :js do
let(:project) { create(:project, :repository, :public) }
let(:merge_request) do
create(:merge_request, source_project: project, source_branch: 'csv', target_branch: 'master')
end
let(:outdated_diff_refs) { project.commit('926c6595b263b2a40da6b17f3e3b7ea08344fad6').diff_refs }
let(:current_diff_refs) { merge_request.diff_refs }
let(:outdated_position) do
Gitlab::Diff::Position.new(
old_path: 'files/csv/Book1.csv',
new_path: 'files/csv/Book1.csv',
old_line: nil,
new_line: 9,
diff_refs: outdated_diff_refs
)
end
let(:current_position) do
Gitlab::Diff::Position.new(
old_path: 'files/csv/Book1.csv',
new_path: 'files/csv/Book1.csv',
old_line: nil,
new_line: 1,
diff_refs: current_diff_refs
)
end
let!(:outdated_discussion) do
create(:diff_note_on_merge_request,
project: project,
noteable: merge_request,
position: outdated_position).to_discussion
end
let!(:current_discussion) do
create(:diff_note_on_merge_request,
noteable: merge_request,
project: project,
position: current_position).to_discussion
end
before do
sign_in(merge_request.author)
end
context 'when a discussion was resolved by a push' do
before do
project.update!(resolve_outdated_diff_discussions: true)
merge_request.update_diff_discussion_positions(
old_diff_refs: outdated_diff_refs,
new_diff_refs: current_diff_refs,
current_user: merge_request.author
)
visit project_merge_request_path(project, merge_request)
end
it 'shows that as automatically resolved' do
within(".discussion[data-discussion-id='#{outdated_discussion.id}']") do
expect(page).not_to have_css('.discussion-body')
expect(page).to have_content('Automatically resolved')
end
end
it 'does not show that for active discussions' do
within(".discussion[data-discussion-id='#{current_discussion.id}']") do
expect(page).to have_css('.discussion-body', visible: true)
expect(page).not_to have_content('Automatically resolved')
end
end
end
end
|