2017-08-30 17:58:19 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-01 22:39:22 +00:00
|
|
|
feature 'Resolve outdated diff discussions', js: true do
|
2017-08-30 17:58:19 +00:00
|
|
|
let(:merge_request) { create(:merge_request, importing: true) }
|
|
|
|
let(:project) { merge_request.source_project }
|
|
|
|
|
|
|
|
let!(:outdated_discussion) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: outdated_position).to_discussion }
|
|
|
|
let!(:active_discussion) { create(:diff_note_on_merge_request, noteable: merge_request, project: project).to_discussion }
|
|
|
|
|
|
|
|
let(:outdated_position) do
|
|
|
|
Gitlab::Diff::Position.new(
|
|
|
|
old_path: "files/ruby/popen.rb",
|
|
|
|
new_path: "files/ruby/popen.rb",
|
|
|
|
old_line: nil,
|
|
|
|
new_line: 9,
|
|
|
|
diff_refs: outdated_diff_refs
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:outdated_diff_refs) { project.commit("874797c3a73b60d2187ed6e2fcabd289ff75171e").diff_refs }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(create(:admin))
|
|
|
|
end
|
|
|
|
|
2017-09-01 22:39:22 +00:00
|
|
|
context 'when project.resolve_outdated_diff_discussions == true' do
|
2017-08-30 17:58:19 +00:00
|
|
|
before do
|
2017-09-01 22:39:22 +00:00
|
|
|
project.update_column(:resolve_outdated_diff_discussions, true)
|
2017-08-30 17:58:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with unresolved outdated discussions' do
|
|
|
|
it 'does not show outdated discussion' do
|
|
|
|
visit_merge_request(merge_request)
|
|
|
|
within(".discussion[data-discussion-id='#{outdated_discussion.id}']") do
|
|
|
|
expect(page).to have_css('.discussion-body .hide .js-toggle-content', visible: false)
|
2017-09-01 22:39:22 +00:00
|
|
|
expect(page).to have_content('Automatically resolved')
|
2017-08-30 17:58:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with unresolved active discussions' do
|
|
|
|
it 'shows active discussion' do
|
|
|
|
visit_merge_request(merge_request)
|
|
|
|
within(".discussion[data-discussion-id='#{active_discussion.id}']") do
|
|
|
|
expect(page).to have_css('.discussion-body .hide .js-toggle-content', visible: true)
|
2017-09-01 22:39:22 +00:00
|
|
|
expect(page).not_to have_content('Automatically resolved')
|
2017-08-30 17:58:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-01 22:39:22 +00:00
|
|
|
context 'when project.resolve_outdated_diff_discussions == false' do
|
2017-08-30 17:58:19 +00:00
|
|
|
before do
|
2017-09-01 22:39:22 +00:00
|
|
|
project.update_column(:resolve_outdated_diff_discussions, false)
|
2017-08-30 17:58:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with unresolved outdated discussions' do
|
|
|
|
it 'shows outdated discussion' do
|
|
|
|
visit_merge_request(merge_request)
|
|
|
|
within(".discussion[data-discussion-id='#{outdated_discussion.id}']") do
|
|
|
|
expect(page).to have_css('.discussion-body .hide .js-toggle-content', visible: true)
|
2017-09-01 22:39:22 +00:00
|
|
|
expect(page).not_to have_content('Automatically resolved')
|
2017-08-30 17:58:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with unresolved active discussions' do
|
|
|
|
it 'shows active discussion' do
|
|
|
|
visit_merge_request(merge_request)
|
|
|
|
within(".discussion[data-discussion-id='#{active_discussion.id}']") do
|
|
|
|
expect(page).to have_css('.discussion-body .hide .js-toggle-content', visible: true)
|
2017-09-01 22:39:22 +00:00
|
|
|
expect(page).not_to have_content('Automatically resolved')
|
2017-08-30 17:58:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def visit_merge_request(merge_request)
|
|
|
|
visit project_merge_request_path(project, merge_request)
|
|
|
|
end
|
|
|
|
end
|