Apply rubocop Rails/FindBy rule everywhere

We didn't detect these cases because by default the rule only searches
for offenses in `app/models/`.
This commit is contained in:
Javi Martín
2019-11-08 18:49:57 +01:00
parent 84bbd81d95
commit ea2aeab383
28 changed files with 48 additions and 44 deletions

View File

@@ -33,9 +33,12 @@ class Legislation::AnnotationsController < Legislation::BaseController
render(json: {}, status: :not_found) && return
end
existing_annotation = @draft_version.annotations.where(
range_start: annotation_params[:ranges].first[:start], range_start_offset: annotation_params[:ranges].first[:startOffset].to_i,
range_end: annotation_params[:ranges].first[:end], range_end_offset: annotation_params[:ranges].first[:endOffset].to_i).first
existing_annotation = @draft_version.annotations.find_by(
range_start: annotation_params[:ranges].first[:start],
range_start_offset: annotation_params[:ranges].first[:startOffset].to_i,
range_end: annotation_params[:ranges].first[:end],
range_end_offset: annotation_params[:ranges].first[:endOffset].to_i
)
@annotation = existing_annotation
if @annotation.present?