summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2019-08-08 15:39:13 +0000
committerRobert Speicher <rspeicher@gmail.com>2019-08-08 15:39:13 +0000
commit79bff3ee7a0d2d91faedeadb1965966f7551b62c (patch)
tree68eba87aa05e474ef8e600bf5e052c5dd08bce5a /lib
parentf541889f4afd4457abe6ded8e48f6a8572bf341d (diff)
parentc69a47049c62f3b6b8b4f426ee498690bc45d3e6 (diff)
downloadgitlab-ce-79bff3ee7a0d2d91faedeadb1965966f7551b62c.tar.gz
Merge branch '12026-use-notes-finder-target-for-epics-ce' into 'master'
Use NotesFinder#target to find Epics See merge request gitlab-org/gitlab-ce!31408
Diffstat (limited to 'lib')
-rw-r--r--lib/api/helpers/notes_helpers.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/api/helpers/notes_helpers.rb b/lib/api/helpers/notes_helpers.rb
index 7124ac0c5c3..6bf9057fad7 100644
--- a/lib/api/helpers/notes_helpers.rb
+++ b/lib/api/helpers/notes_helpers.rb
@@ -74,14 +74,14 @@ module API
end
def find_noteable(parent_type, parent_id, noteable_type, noteable_id)
- params = params_by_noteable_type_and_id(noteable_type, noteable_id)
+ params = finder_params_by_noteable_type_and_id(noteable_type, noteable_id, parent_id)
- noteable = NotesFinder.new(current_user, params.merge(project: user_project)).target
+ noteable = NotesFinder.new(current_user, params).target
noteable = nil unless can?(current_user, noteable_read_ability_name(noteable), noteable)
noteable || not_found!(noteable_type)
end
- def params_by_noteable_type_and_id(type, id)
+ def finder_params_by_noteable_type_and_id(type, id, parent_id)
target_type = type.name.underscore
{ target_type: target_type }.tap do |h|
if %w(issue merge_request).include?(target_type)
@@ -89,9 +89,15 @@ module API
else
h[:target_id] = id
end
+
+ add_parent_to_finder_params(h, type, parent_id)
end
end
+ def add_parent_to_finder_params(finder_params, noteable_type, parent_id)
+ finder_params[:project] = user_project
+ end
+
def noteable_parent(noteable)
public_send("user_#{noteable.class.parent_class.to_s.underscore}") # rubocop:disable GitlabSecurity/PublicSend
end