Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPatrick Derichs <pderichs@gitlab.com>2019-06-15 08:10:58 +0300
committerPatrick Derichs <pderichs@gitlab.com>2019-06-19 11:56:55 +0300
commit932a9a0c77a02e1d948f45cffe5e936e915ae0bc (patch)
treecb1766d65bc00f56c83a044b6fc19712a9473f69 /app
parentba952d53c5782e49b59ba3e5dd89c2c1eca02c80 (diff)
Use NotesFinder to fetch notes on API and Controllers
Fix missing iid query on NotesFinder Changed parameters of find_noteable, so changes across a few files were needed. MergeRequest also requires iid instead of id query Make NotesFinder fail with RecordNotFound again Add specs for target_iid Using RSpec tablesyntax for target_iid specs Revert "Using RSpec tablesyntax for target_iid specs" This reverts commit ba45c7f569a. Allow find_by! here Fix variable name Add readable check Revert "Add readable check" This reverts commit 9e3a1a7aa39. Remove unnecessary assignment Add required changes for EE Fix parameter count Reduce code duplication by extracting a noteable module method The call to find_noteable was redundant so multiple files and lines have changed in that commit to use the newly introduced module method `noteable`. Replace casecmp with include check Add parent_type parameter Revert "Reduce code duplication by extracting a noteable module method" This reverts commit 8c0923babff16. Method is no longer needed Check whether noteable can be read by user
Diffstat (limited to 'app')
-rw-r--r--app/finders/notes_finder.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/app/finders/notes_finder.rb b/app/finders/notes_finder.rb
index 817aac8b5d5..83bf015488f 100644
--- a/app/finders/notes_finder.rb
+++ b/app/finders/notes_finder.rb
@@ -34,8 +34,9 @@ class NotesFinder
target_type = @params[:target_type]
target_id = @params[:target_id]
+ target_iid = @params[:target_iid]
- return @target = nil unless target_type && target_id
+ return @target = nil unless target_type && (target_id || target_iid)
@target =
if target_type == "commit"
@@ -43,12 +44,22 @@ class NotesFinder
@project.commit(target_id)
end
else
- noteables_for_type(target_type).find(target_id)
+ noteables_for_type_by_id(target_type, target_id, target_iid)
end
end
private
+ def noteables_for_type_by_id(type, id, iid)
+ query = if id
+ { id: id }
+ else
+ { iid: iid }
+ end
+
+ noteables_for_type(type).find_by!(query) # rubocop: disable CodeReuse/ActiveRecord
+ end
+
def init_collection
if target
notes_on_target