2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-30 17:58:19 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 18:09:01 +00:00
|
|
|
RSpec.describe 'Merge request > User resolves outdated diff discussions', :js do
|
2017-09-05 15:49:05 +00:00
|
|
|
let(:project) { create(:project, :repository, :public) }
|
2017-08-30 17:58:19 +00:00
|
|
|
|
2017-09-05 15:49:05 +00:00
|
|
|
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 }
|
2017-08-30 17:58:19 +00:00
|
|
|
|
|
|
|
let(:outdated_position) do
|
2020-02-17 18:09:00 +00:00
|
|
|
build(:text_diff_position, :added,
|
|
|
|
file: 'files/csv/Book1.csv',
|
2017-08-30 17:58:19 +00:00
|
|
|
new_line: 9,
|
|
|
|
diff_refs: outdated_diff_refs
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2017-09-05 15:49:05 +00:00
|
|
|
let(:current_position) do
|
2020-02-17 18:09:00 +00:00
|
|
|
build(:text_diff_position, :added,
|
|
|
|
file: 'files/csv/Book1.csv',
|
2017-09-05 15:49:05 +00:00
|
|
|
new_line: 1,
|
|
|
|
diff_refs: current_diff_refs
|
|
|
|
)
|
2017-08-30 17:58:19 +00:00
|
|
|
end
|
|
|
|
|
2017-09-05 15:49:05 +00:00
|
|
|
let!(:outdated_discussion) do
|
|
|
|
create(:diff_note_on_merge_request,
|
|
|
|
project: project,
|
|
|
|
noteable: merge_request,
|
|
|
|
position: outdated_position).to_discussion
|
|
|
|
end
|
2017-08-30 17:58:19 +00:00
|
|
|
|
2017-09-05 15:49:05 +00:00
|
|
|
let!(:current_discussion) do
|
|
|
|
create(:diff_note_on_merge_request,
|
|
|
|
noteable: merge_request,
|
|
|
|
project: project,
|
|
|
|
position: current_position).to_discussion
|
|
|
|
end
|
2017-08-30 17:58:19 +00:00
|
|
|
|
2017-09-05 15:49:05 +00:00
|
|
|
before do
|
|
|
|
sign_in(merge_request.author)
|
2017-08-30 17:58:19 +00:00
|
|
|
end
|
|
|
|
|
2017-09-05 15:49:05 +00:00
|
|
|
context 'when a discussion was resolved by a push' do
|
2017-08-30 17:58:19 +00:00
|
|
|
before do
|
2017-09-05 15:49:05 +00:00
|
|
|
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)
|
2017-08-30 17:58:19 +00:00
|
|
|
end
|
|
|
|
|
2017-09-05 15:49:05 +00:00
|
|
|
it 'shows that as automatically resolved' do
|
|
|
|
within(".discussion[data-discussion-id='#{outdated_discussion.id}']") do
|
2018-06-21 12:22:40 +00:00
|
|
|
expect(page).not_to have_css('.discussion-body')
|
2017-09-05 15:49:05 +00:00
|
|
|
expect(page).to have_content('Automatically resolved')
|
2017-08-30 17:58:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-05 15:49:05 +00:00
|
|
|
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')
|
2017-08-30 17:58:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|