summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-05-22 15:56:20 -0500
committerDouwe Maan <douwe@selenight.nl>2017-05-23 16:27:30 -0500
commit6e698b254ecddf23a866d9e98a885912102ccbce (patch)
tree3ce0ea2a254bb9f6148615295ac2ccce5794cf6b
parent14a0841acda66d896b3a7f4459ec0fc4fc44f7f2 (diff)
downloadgitlab-ce-dm-outdated-system-note.tar.gz
-rw-r--r--app/models/note.rb7
-rw-r--r--lib/gitlab/diff/position_tracer.rb1
-rw-r--r--spec/features/merge_requests/discussion_spec.rb2
-rw-r--r--spec/helpers/notes_helper_spec.rb8
-rw-r--r--spec/lib/gitlab/import_export/safe_model_attributes.yml1
5 files changed, 14 insertions, 5 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index b4228cc6492..fc8baa66b2f 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -121,7 +121,7 @@ class Note < ActiveRecord::Base
end
def grouped_diff_discussions(diff_refs = nil)
- groups = Hash.new { |h, k| h[k] = [] }
+ groups = {}
diff_notes.fresh.discussions.each do |discussion|
line_code =
@@ -131,7 +131,10 @@ class Note < ActiveRecord::Base
discussion.original_line_code
end
- groups[line_code] << discussion if line_code
+ if line_code
+ discussions = groups[line_code] ||= []
+ discussions << discussion
+ end
end
groups
diff --git a/lib/gitlab/diff/position_tracer.rb b/lib/gitlab/diff/position_tracer.rb
index 3705361a185..46f8f7e8238 100644
--- a/lib/gitlab/diff/position_tracer.rb
+++ b/lib/gitlab/diff/position_tracer.rb
@@ -168,7 +168,6 @@ module Gitlab
bd_diff = bd_diffs.diff_file_with_old_path(b_path)
- d_path = bd_diff&.new_path || b_path
d_line = LineMapper.new(bd_diff).old_to_new(b_line)
cd_diff = cd_diffs.diff_file_with_old_path(c_path)
diff --git a/spec/features/merge_requests/discussion_spec.rb b/spec/features/merge_requests/discussion_spec.rb
index f59d0faa274..1a09cc54c2e 100644
--- a/spec/features/merge_requests/discussion_spec.rb
+++ b/spec/features/merge_requests/discussion_spec.rb
@@ -43,7 +43,7 @@ feature 'Merge Request Discussions', feature: true do
it 'shows a link to the outdated diff' do
within(".discussion[data-discussion-id='#{outdated_discussion.id}']") do
path = diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, diff_id: old_merge_request_diff.id, anchor: outdated_discussion.line_code)
- expect(page).to have_link('an outdated diff', href: path)
+ expect(page).to have_link('an old version of the diff', href: path)
end
end
end
diff --git a/spec/helpers/notes_helper_spec.rb b/spec/helpers/notes_helper_spec.rb
index 099146678ae..355a4845afb 100644
--- a/spec/helpers/notes_helper_spec.rb
+++ b/spec/helpers/notes_helper_spec.rb
@@ -92,7 +92,13 @@ describe NotesHelper do
)
end
- let(:discussion) { create(:diff_note_on_merge_request, noteable: merge_request, project: project, position: position).to_discussion }
+ let(:diff_note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project, position: position) }
+ let(:discussion) { diff_note.to_discussion }
+
+ before do
+ diff_note.position = diff_note.original_position
+ diff_note.save!
+ end
it 'returns the diff version comparison path with the line code' do
expect(helper.discussion_path(discussion)).to eq(diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, diff_id: merge_request_diff3, start_sha: merge_request_diff1.head_commit_sha, anchor: discussion.line_code))
diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml
index c22fba11225..96054c996fd 100644
--- a/spec/lib/gitlab/import_export/safe_model_attributes.yml
+++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml
@@ -54,6 +54,7 @@ Note:
- type
- position
- original_position
+- change_position
- resolved_at
- resolved_by_id
- discussion_id