Commit afa53810 authored by Douwe Maan's avatar Douwe Maan Committed by Luke "Jared" Bennett

Fix specs

parent 21e10888
...@@ -769,6 +769,10 @@ require('./task_list'); ...@@ -769,6 +769,10 @@ require('./task_list');
form.find('.js-note-new-discussion').remove(); form.find('.js-note-new-discussion').remove();
this.setupNoteForm(form); this.setupNoteForm(form);
form
.removeClass('js-main-target-form')
.addClass("discussion-form js-discussion-note-form");
if (typeof gl.diffNotesCompileComponents !== 'undefined') { if (typeof gl.diffNotesCompileComponents !== 'undefined') {
var $commentBtn = form.find('comment-and-resolve-btn'); var $commentBtn = form.find('comment-and-resolve-btn');
$commentBtn.attr(':discussion-id', "'" + discussionID + "'"); $commentBtn.attr(':discussion-id', "'" + discussionID + "'");
...@@ -780,9 +784,6 @@ require('./task_list'); ...@@ -780,9 +784,6 @@ require('./task_list');
form form
.find('.js-comment-resolve-button') .find('.js-comment-resolve-button')
.attr('data-discussion-id', discussionID); .attr('data-discussion-id', discussionID);
form
.removeClass('js-main-target-form')
.addClass("discussion-form js-discussion-note-form");
}; };
/* /*
......
...@@ -98,9 +98,9 @@ class NotesFinder ...@@ -98,9 +98,9 @@ class NotesFinder
# #
# This method uses ILIKE on PostgreSQL and LIKE on MySQL. # This method uses ILIKE on PostgreSQL and LIKE on MySQL.
# #
def search(query, notes) def search(notes)
query = @params[:search] query = @params[:search]
return unless query return notes unless query
pattern = "%#{query}%" pattern = "%#{query}%"
notes.where(Note.arel_table[:note].matches(pattern)) notes.where(Note.arel_table[:note].matches(pattern))
......
- discussion = @note.discussion unless @discussion.individual_note? - discussion = @note.discussion if @note.part_of_discussion?
- if discussion - if discussion
%p.details %p.details
= succeed ':' do = succeed ':' do
......
<% discussion = @note.discussion unless @discussion.individual_note? -%> <% discussion = @note.discussion if @note.part_of_discussion? -%>
<% if discussion && !discussion.individual_note? -%> <% if discussion && !discussion.individual_note? -%>
<%= @note.author_name -%> <%= @note.author_name -%>
<% if discussion.new_discussion? -%> <% if discussion.new_discussion? -%>
......
...@@ -42,7 +42,7 @@ module Gitlab ...@@ -42,7 +42,7 @@ module Gitlab
def encode_with(coder) def encode_with(coder)
coder['attributes'] = self.to_h coder['attributes'] = self.to_h
end end
def key def key
@key ||= [base_sha, start_sha, head_sha, Digest::SHA1.hexdigest(old_path || ""), Digest::SHA1.hexdigest(new_path || ""), old_line, new_line] @key ||= [base_sha, start_sha, head_sha, Digest::SHA1.hexdigest(old_path || ""), Digest::SHA1.hexdigest(new_path || ""), old_line, new_line]
end end
......
...@@ -163,11 +163,9 @@ feature 'Diff note avatars', feature: true, js: true do ...@@ -163,11 +163,9 @@ feature 'Diff note avatars', feature: true, js: true do
end end
context 'multiple comments' do context 'multiple comments' do
before do let!(:notes) { create_list(:diff_note_on_merge_request, 3, project: project, noteable: merge_request, in_reply_to: note) }
create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: position)
create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: position)
create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: position)
before do
visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, view: view) visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, view: view)
wait_for_ajax wait_for_ajax
......
...@@ -191,7 +191,7 @@ feature 'Diff notes resolve', feature: true, js: true do ...@@ -191,7 +191,7 @@ feature 'Diff notes resolve', feature: true, js: true do
context 'multiple notes' do context 'multiple notes' do
before do before do
create(:diff_note_on_merge_request, project: project, noteable: merge_request) create(:diff_note_on_merge_request, project: project, noteable: merge_request, in_reply_to: note)
visit_merge_request visit_merge_request
end end
......
...@@ -36,21 +36,4 @@ describe NotesHelper do ...@@ -36,21 +36,4 @@ describe NotesHelper do
expect(helper.note_max_access_for_user(other_note)).to eq('Reporter') expect(helper.note_max_access_for_user(other_note)).to eq('Reporter')
end end
end end
describe '#preload_max_access_for_authors' do
before do
# This method reads cache from RequestStore, so make sure it's clean.
RequestStore.clear!
end
it 'loads multiple users' do
expected_access = {
owner.id => Gitlab::Access::OWNER,
master.id => Gitlab::Access::MASTER,
reporter.id => Gitlab::Access::REPORTER
}
expect(helper.preload_max_access_for_authors(notes, project)).to eq(expected_access)
end
end
end end
...@@ -55,6 +55,7 @@ Note: ...@@ -55,6 +55,7 @@ Note:
- resolved_at - resolved_at
- resolved_by_id - resolved_by_id
- discussion_id - discussion_id
- original_discussion_id
LabelLink: LabelLink:
- id - id
- label_id - label_id
......
...@@ -755,7 +755,7 @@ describe Notify do ...@@ -755,7 +755,7 @@ describe Notify do
end end
shared_examples 'an email for a note on a diff discussion' do |model| shared_examples 'an email for a note on a diff discussion' do |model|
let(:note) { create(model, project: project, author: note_author) } let(:note) { create(model, author: note_author) }
it "includes diffs with character-level highlighting" do it "includes diffs with character-level highlighting" do
is_expected.to have_body_text '<span class="p">}</span></span>' is_expected.to have_body_text '<span class="p">}</span></span>'
......
...@@ -4,14 +4,14 @@ describe MergeRequest, Noteable, model: true do ...@@ -4,14 +4,14 @@ describe MergeRequest, Noteable, model: true do
let(:merge_request) { create(:merge_request) } let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.project } let(:project) { merge_request.project }
let!(:active_diff_note1) { create(:diff_note_on_merge_request, project: project, noteable: merge_request) } let!(:active_diff_note1) { create(:diff_note_on_merge_request, project: project, noteable: merge_request) }
let!(:active_diff_note2) { create(:diff_note_on_merge_request, project: project, noteable: merge_request) } let!(:active_diff_note2) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, in_reply_to: active_diff_note1) }
let!(:active_diff_note3) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: active_position2) } let!(:active_diff_note3) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: active_position2) }
let!(:outdated_diff_note1) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: outdated_position) } let!(:outdated_diff_note1) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: outdated_position) }
let!(:outdated_diff_note2) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: outdated_position) } let!(:outdated_diff_note2) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: outdated_position, in_reply_to: outdated_diff_note1) }
let!(:discussion_note1) { create(:discussion_note_on_merge_request, project: project, noteable: merge_request) } let!(:discussion_note1) { create(:discussion_note_on_merge_request, project: project, noteable: merge_request) }
let!(:discussion_note2) { create(:discussion_note_on_merge_request, in_reply_to: discussion_note1) } let!(:discussion_note2) { create(:discussion_note_on_merge_request, in_reply_to: discussion_note1) }
let!(:commit_diff_note1) { create(:diff_note_on_commit, project: project) } let!(:commit_diff_note1) { create(:diff_note_on_commit, project: project) }
let!(:commit_diff_note2) { create(:diff_note_on_commit, project: project) } let!(:commit_diff_note2) { create(:diff_note_on_commit, project: project, in_reply_to: commit_diff_note1) }
let!(:commit_note1) { create(:note_on_commit, project: project) } let!(:commit_note1) { create(:note_on_commit, project: project) }
let!(:commit_note2) { create(:note_on_commit, project: project) } let!(:commit_note2) { create(:note_on_commit, project: project) }
let!(:commit_discussion_note1) { create(:discussion_note_on_commit, project: project) } let!(:commit_discussion_note1) { create(:discussion_note_on_commit, project: project) }
...@@ -63,7 +63,7 @@ describe MergeRequest, Noteable, model: true do ...@@ -63,7 +63,7 @@ describe MergeRequest, Noteable, model: true do
subject { merge_request.grouped_diff_discussions } subject { merge_request.grouped_diff_discussions }
it "includes active discussions" do it "includes active discussions" do
discussions = subject.values discussions = subject.values.flatten
expect(discussions.count).to eq(2) expect(discussions.count).to eq(2)
expect(discussions.map(&:id)).to eq([active_diff_note1.discussion_id, active_diff_note3.discussion_id]) expect(discussions.map(&:id)).to eq([active_diff_note1.discussion_id, active_diff_note3.discussion_id])
...@@ -74,12 +74,12 @@ describe MergeRequest, Noteable, model: true do ...@@ -74,12 +74,12 @@ describe MergeRequest, Noteable, model: true do
end end
it "doesn't include outdated discussions" do it "doesn't include outdated discussions" do
expect(subject.values.map(&:id)).not_to include(outdated_diff_note1.discussion_id) expect(subject.values.flatten.map(&:id)).not_to include(outdated_diff_note1.discussion_id)
end end
it "groups the discussions by line code" do it "groups the discussions by line code" do
expect(subject[active_diff_note1.line_code].id).to eq(active_diff_note1.discussion_id) expect(subject[active_diff_note1.line_code].first.id).to eq(active_diff_note1.discussion_id)
expect(subject[active_diff_note3.line_code].id).to eq(active_diff_note3.discussion_id) expect(subject[active_diff_note3.line_code].first.id).to eq(active_diff_note3.discussion_id)
end end
end end
end end
This diff is collapsed.
This diff is collapsed.
...@@ -263,10 +263,10 @@ describe Note, models: true do ...@@ -263,10 +263,10 @@ describe Note, models: true do
let!(:merge_request) { create(:merge_request) } let!(:merge_request) { create(:merge_request) }
let(:project) { merge_request.project } let(:project) { merge_request.project }
let!(:active_diff_note1) { create(:diff_note_on_merge_request, project: project, noteable: merge_request) } let!(:active_diff_note1) { create(:diff_note_on_merge_request, project: project, noteable: merge_request) }
let!(:active_diff_note2) { create(:diff_note_on_merge_request, project: project, noteable: merge_request) } let!(:active_diff_note2) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, in_reply_to: active_diff_note1) }
let!(:active_diff_note3) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: active_position2) } let!(:active_diff_note3) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: active_position2) }
let!(:outdated_diff_note1) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: outdated_position) } let!(:outdated_diff_note1) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: outdated_position) }
let!(:outdated_diff_note2) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: outdated_position) } let!(:outdated_diff_note2) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, in_reply_to: outdated_diff_note1) }
let(:active_position2) do let(:active_position2) do
Gitlab::Diff::Position.new( Gitlab::Diff::Position.new(
...@@ -291,7 +291,7 @@ describe Note, models: true do ...@@ -291,7 +291,7 @@ describe Note, models: true do
subject { merge_request.notes.grouped_diff_discussions } subject { merge_request.notes.grouped_diff_discussions }
it "includes active discussions" do it "includes active discussions" do
discussions = subject.values discussions = subject.values.flatten
expect(discussions.count).to eq(2) expect(discussions.count).to eq(2)
expect(discussions.map(&:id)).to eq([active_diff_note1.discussion_id, active_diff_note3.discussion_id]) expect(discussions.map(&:id)).to eq([active_diff_note1.discussion_id, active_diff_note3.discussion_id])
...@@ -302,12 +302,12 @@ describe Note, models: true do ...@@ -302,12 +302,12 @@ describe Note, models: true do
end end
it "doesn't include outdated discussions" do it "doesn't include outdated discussions" do
expect(subject.values.map(&:id)).not_to include(outdated_diff_note1.discussion_id) expect(subject.values.flatten.map(&:id)).not_to include(outdated_diff_note1.discussion_id)
end end
it "groups the discussions by line code" do it "groups the discussions by line code" do
expect(subject[active_diff_note1.line_code].id).to eq(active_diff_note1.discussion_id) expect(subject[active_diff_note1.line_code].first.id).to eq(active_diff_note1.discussion_id)
expect(subject[active_diff_note3.line_code].id).to eq(active_diff_note3.discussion_id) expect(subject[active_diff_note3.line_code].first.id).to eq(active_diff_note3.discussion_id)
end end
end end
......
...@@ -91,9 +91,7 @@ describe Issues::BuildService, services: true do ...@@ -91,9 +91,7 @@ describe Issues::BuildService, services: true do
end end
describe 'with multiple discussions' do describe 'with multiple discussions' do
before do let!(:diff_note) { create(:diff_note_on_merge_request, noteable: merge_request, project: merge_request.target_project, line_number: 15) }
create(:diff_note_on_merge_request, noteable: merge_request, project: merge_request.target_project, line_number: 15)
end
it 'mentions all the authors in the description' do it 'mentions all the authors in the description' do
authors = merge_request.resolvable_discussions.map(&:author) authors = merge_request.resolvable_discussions.map(&:author)
...@@ -109,7 +107,7 @@ describe Issues::BuildService, services: true do ...@@ -109,7 +107,7 @@ describe Issues::BuildService, services: true do
end end
it 'mentions additional notes' do it 'mentions additional notes' do
create_list(:diff_note_on_merge_request, 2, noteable: merge_request, project: merge_request.target_project, line_number: 15) create_list(:diff_note_on_merge_request, 2, noteable: merge_request, project: merge_request.target_project, in_reply_to: diff_note)
expect(issue.description).to include('(+2 comments)') expect(issue.description).to include('(+2 comments)')
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment