2017-08-01 18:03:07 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2019-06-14 09:18:03 +00:00
|
|
|
describe 'Merge request > User sees threads', :js do
|
2017-08-01 18:03:07 +00:00
|
|
|
let(:project) { create(:project, :public, :repository) }
|
|
|
|
let(:user) { project.creator }
|
|
|
|
let(:merge_request) { create(:merge_request, source_project: project) }
|
2017-04-10 20:17:47 +00:00
|
|
|
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-08-01 18:03:07 +00:00
|
|
|
sign_in(user)
|
2017-04-10 20:17:47 +00:00
|
|
|
end
|
|
|
|
|
2017-06-01 14:05:21 +00:00
|
|
|
describe "Diff discussions" do
|
2017-04-10 20:17:47 +00:00
|
|
|
let!(:old_merge_request_diff) { merge_request.merge_request_diffs.create(diff_refs: outdated_diff_refs) }
|
|
|
|
let!(:new_merge_request_diff) { merge_request.merge_request_diffs.create }
|
|
|
|
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 }
|
|
|
|
|
2017-08-10 22:31:42 +00:00
|
|
|
before do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2017-04-10 20:17:47 +00:00
|
|
|
end
|
|
|
|
|
2019-06-14 09:18:03 +00:00
|
|
|
context 'active threads' do
|
2017-04-10 20:17:47 +00:00
|
|
|
it 'shows a link to the diff' do
|
|
|
|
within(".discussion[data-discussion-id='#{active_discussion.id}']") do
|
2017-07-06 16:20:50 +00:00
|
|
|
path = diffs_project_merge_request_path(project, merge_request, anchor: active_discussion.line_code)
|
2017-04-10 20:17:47 +00:00
|
|
|
expect(page).to have_link('the diff', href: path)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-14 09:18:03 +00:00
|
|
|
context 'outdated threads' do
|
2017-04-10 20:17:47 +00:00
|
|
|
it 'shows a link to the outdated diff' do
|
|
|
|
within(".discussion[data-discussion-id='#{outdated_discussion.id}']") do
|
2017-07-06 16:20:50 +00:00
|
|
|
path = diffs_project_merge_request_path(project, merge_request, diff_id: old_merge_request_diff.id, anchor: outdated_discussion.line_code)
|
2017-05-22 20:56:20 +00:00
|
|
|
expect(page).to have_link('an old version of the diff', href: path)
|
2017-04-10 20:17:47 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-06-01 14:05:21 +00:00
|
|
|
|
|
|
|
describe 'Commit comments displayed in MR context', :js do
|
|
|
|
shared_examples 'a functional discussion' do
|
|
|
|
let(:discussion_id) { note.discussion_id(merge_request) }
|
|
|
|
|
2018-11-26 23:16:10 +00:00
|
|
|
it 'is displayed' do
|
2017-06-01 14:05:21 +00:00
|
|
|
expect(page).to have_css(".discussion[data-discussion-id='#{discussion_id}']")
|
|
|
|
end
|
|
|
|
|
2018-11-26 23:16:10 +00:00
|
|
|
it 'can be replied to' do
|
2017-06-01 14:05:21 +00:00
|
|
|
within(".discussion[data-discussion-id='#{discussion_id}']") do
|
|
|
|
click_button 'Reply...'
|
|
|
|
fill_in 'note[note]', with: 'Test!'
|
|
|
|
click_button 'Comment'
|
|
|
|
|
|
|
|
expect(page).to have_css('.note', count: 2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-10 22:31:42 +00:00
|
|
|
before do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2017-06-01 14:05:21 +00:00
|
|
|
end
|
|
|
|
|
2018-11-26 23:16:10 +00:00
|
|
|
# TODO: https://gitlab.com/gitlab-org/gitlab-ce/issues/48034
|
|
|
|
# context 'a regular commit comment' do
|
|
|
|
# let(:note) { create(:note_on_commit, project: project) }
|
|
|
|
#
|
|
|
|
# it_behaves_like 'a functional discussion'
|
|
|
|
# end
|
2017-06-01 14:05:21 +00:00
|
|
|
|
|
|
|
context 'a commit diff comment' do
|
|
|
|
let(:note) { create(:diff_note_on_commit, project: project) }
|
|
|
|
|
|
|
|
it_behaves_like 'a functional discussion'
|
2018-11-26 23:16:10 +00:00
|
|
|
|
|
|
|
it 'displays correct header' do
|
2019-06-14 09:18:03 +00:00
|
|
|
expect(page).to have_content "started a thread on commit #{note.commit_id[0...7]}"
|
2018-11-26 23:16:10 +00:00
|
|
|
end
|
2017-06-01 14:05:21 +00:00
|
|
|
end
|
2019-01-17 11:15:33 +00:00
|
|
|
|
|
|
|
context 'a commit non-diff discussion' do
|
|
|
|
let(:note) { create(:discussion_note_on_commit, project: project) }
|
2019-01-21 04:46:27 +00:00
|
|
|
|
2019-01-17 11:15:33 +00:00
|
|
|
it 'displays correct header' do
|
|
|
|
page.within(find("#note_#{note.id}", match: :first)) do
|
2019-01-18 20:23:47 +00:00
|
|
|
refresh # Trigger a refresh of notes.
|
|
|
|
wait_for_requests
|
2019-01-17 11:15:33 +00:00
|
|
|
expect(page).to have_content "commented on commit #{note.commit_id[0...7]}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-06-01 14:05:21 +00:00
|
|
|
end
|
2017-04-10 20:17:47 +00:00
|
|
|
end
|