diff options
Diffstat (limited to 'app/finders/concerns')
-rw-r--r-- | app/finders/concerns/custom_attributes_filter.rb | 2 | ||||
-rw-r--r-- | app/finders/concerns/finder_methods.rb | 4 | ||||
-rw-r--r-- | app/finders/concerns/finder_with_cross_project_access.rb | 2 |
3 files changed, 8 insertions, 0 deletions
diff --git a/app/finders/concerns/custom_attributes_filter.rb b/app/finders/concerns/custom_attributes_filter.rb index 5bbf9ca242d..022a19b0a7f 100644 --- a/app/finders/concerns/custom_attributes_filter.rb +++ b/app/finders/concerns/custom_attributes_filter.rb @@ -1,4 +1,5 @@ module CustomAttributesFilter + # rubocop: disable CodeReuse/ActiveRecord def by_custom_attributes(items) return items unless params[:custom_attributes].is_a?(Hash) return items unless Ability.allowed?(current_user, :read_custom_attribute) @@ -17,4 +18,5 @@ module CustomAttributesFilter scope.where('EXISTS (?)', custom_attributes.where(key: key, value: value)) end end + # rubocop: enable CodeReuse/ActiveRecord end diff --git a/app/finders/concerns/finder_methods.rb b/app/finders/concerns/finder_methods.rb index 2e905fa5750..ce0ec214b8a 100644 --- a/app/finders/concerns/finder_methods.rb +++ b/app/finders/concerns/finder_methods.rb @@ -1,11 +1,15 @@ module FinderMethods + # rubocop: disable CodeReuse/ActiveRecord def find_by!(*args) raise_not_found_unless_authorized execute.find_by!(*args) end + # rubocop: enable CodeReuse/ActiveRecord + # rubocop: disable CodeReuse/ActiveRecord def find_by(*args) if_authorized execute.find_by(*args) end + # rubocop: enable CodeReuse/ActiveRecord def find(*args) raise_not_found_unless_authorized model.find(*args) diff --git a/app/finders/concerns/finder_with_cross_project_access.rb b/app/finders/concerns/finder_with_cross_project_access.rb index 92bf98d7cd2..f70a0b60864 100644 --- a/app/finders/concerns/finder_with_cross_project_access.rb +++ b/app/finders/concerns/finder_with_cross_project_access.rb @@ -14,6 +14,7 @@ module FinderWithCrossProjectAccess end override :execute + # rubocop: disable CodeReuse/ActiveRecord def execute(*args) check = Gitlab::CrossProjectAccess.find_check(self) original = super @@ -27,6 +28,7 @@ module FinderWithCrossProjectAccess original end end + # rubocop: enable CodeReuse/ActiveRecord # We can skip the cross project check for finding indivitual records. # this would be handled by the `can?(:read_*, result)` call in `FinderMethods` |