summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-04-01 08:38:16 +0000
committerDouwe Maan <douwe@gitlab.com>2016-04-01 08:38:16 +0000
commit2e3c2a355fbb362364c27ecceb1f21ef83aeddbb (patch)
tree72c447598f7325b6b76ac0d9203d3b8034f0e635 /lib
parent670f8540fabb37ac83c02738100eea5e69a66369 (diff)
parente60f034126712b7e5a3b3ff9c5e92359aaf96e10 (diff)
downloadgitlab-ce-2e3c2a355fbb362364c27ecceb1f21ef83aeddbb.tar.gz
Merge branch 'snippets-with-comments-cause-a-500-when-they-show-up-in-search-results-14764' into 'master'
Fix Error 500 when searching for a comment in a project snippet Closes #14764. /cc @stanhu, and thank you for the spec! ;) See merge request !3468
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/note_data_builder.rb2
-rw-r--r--lib/gitlab/url_builder.rb14
2 files changed, 7 insertions, 9 deletions
diff --git a/lib/gitlab/note_data_builder.rb b/lib/gitlab/note_data_builder.rb
index 71cf6a0d886..18523e0aefe 100644
--- a/lib/gitlab/note_data_builder.rb
+++ b/lib/gitlab/note_data_builder.rb
@@ -41,7 +41,7 @@ module Gitlab
data[:issue] = note.noteable.hook_attrs
elsif note.for_merge_request?
data[:merge_request] = note.noteable.hook_attrs
- elsif note.for_project_snippet?
+ elsif note.for_snippet?
data[:snippet] = note.noteable.hook_attrs
end
diff --git a/lib/gitlab/url_builder.rb b/lib/gitlab/url_builder.rb
index 6f0d02cafd1..e157bb96f2a 100644
--- a/lib/gitlab/url_builder.rb
+++ b/lib/gitlab/url_builder.rb
@@ -2,6 +2,7 @@ module Gitlab
class UrlBuilder
include Gitlab::Application.routes.url_helpers
include GitlabRoutingHelper
+ include ActionView::RecordIdentifier
def initialize(type)
@type = type
@@ -37,19 +38,16 @@ module Gitlab
namespace_project_commit_url(namespace_id: note.project.namespace,
id: note.commit_id,
project_id: note.project,
- anchor: "note_#{note.id}")
+ anchor: dom_id(note))
elsif note.for_issue?
issue = Issue.find(note.noteable_id)
- issue_url(issue,
- anchor: "note_#{note.id}")
+ issue_url(issue, anchor: dom_id(note))
elsif note.for_merge_request?
merge_request = MergeRequest.find(note.noteable_id)
- merge_request_url(merge_request,
- anchor: "note_#{note.id}")
- elsif note.for_project_snippet?
+ merge_request_url(merge_request, anchor: dom_id(note))
+ elsif note.for_snippet?
snippet = Snippet.find(note.noteable_id)
- project_snippet_url(snippet,
- anchor: "note_#{note.id}")
+ project_snippet_url(snippet, anchor: dom_id(note))
end
end
end