Apply Rails/Validation rubocop rule

This commit is contained in:
Javi Martín
2019-06-23 00:46:28 +02:00
parent 27c73c22ea
commit 0788925c1b
5 changed files with 8 additions and 14 deletions

View File

@@ -165,9 +165,6 @@ Rails/SkipsModelValidations:
Rails/UniqBeforePluck:
Enabled: true
Rails/Validation:
Enabled: true
RSpec/AlignLeftLetBrace:
Enabled: false

View File

@@ -157,6 +157,9 @@ Rails/UnknownEnv:
- preproduction
- staging
Rails/Validation:
Enabled: true
RSpec/NotToNot:
Enabled: true

View File

@@ -1,8 +1,7 @@
class Budget
class ContentBlock < ApplicationRecord
validates :locale, presence: true, inclusion: { in: I18n.available_locales.map(&:to_s) }
validates :heading, presence: true
validates_uniqueness_of :heading, scope: :locale
validates :heading, presence: true, uniqueness: { scope: :locale }
belongs_to :heading
end

View File

@@ -3,12 +3,10 @@ class Newsletter < ApplicationRecord
validates :subject, presence: true
validates :segment_recipient, presence: true
validates :from, presence: true
validates :from, presence: true, format: { with: /@/ }
validates :body, presence: true
validate :validate_segment_recipient
validates_format_of :from, :with => /@/
acts_as_paranoid column: :hidden_at
include ActsAsParanoidAliases

View File

@@ -30,12 +30,9 @@ class VotationType < ApplicationRecord
validates :questionable, presence: true
validates :questionable_type, inclusion: { in: QUESTIONABLE_TYPES }
validates_presence_of :max_votes, allow_blank: false,
if: :max_votes_required?
validates_presence_of :max_groups_answers, allow_blank: false,
if: :max_groups_answers_required?
validates_presence_of :prioritization_type, allow_blank: false,
if: :prioritization_type_required?
validates :max_votes, presence: { allow_blank: false, if: :max_votes_required? }
validates :max_groups_answers, presence: { allow_blank: false, if: :max_groups_answers_required? }
validates :prioritization_type, presence: { allow_blank: false, if: :prioritization_type_required? }
after_create :add_skip_question_answer, if: :display_skip_question?