Add and apply Rails/WhereRange rubocop rule

This rule was added in rubocop-rails 2.25.0. Applying it allows us to
simplify the code a little bit. For example, now there's no need to
specify the `proposals` table in proposal scopes, which was actually
causing a bug in the `Legislation::Proposal` model, which was using the
`proposals` table instead of the `legislation_proposals` table (but,
since we don't use this scope, it didn't affect the application).
This commit is contained in:
Javi Martín
2024-07-02 17:00:29 +02:00
parent 8e2bd12c7e
commit fb0c087f95
12 changed files with 28 additions and 27 deletions

View File

@@ -14,7 +14,7 @@ class Milestone < ApplicationRecord
validates_translation :description, presence: true, unless: -> { status_id.present? }
scope :order_by_publication_date, -> { order(publication_date: :asc, created_at: :asc) }
scope :published, -> { where("publication_date <= ?", Date.current.end_of_day) }
scope :published, -> { where(publication_date: ..Date.current.end_of_day) }
scope :with_status, -> { where.not(status_id: nil) }
def self.title_max_length