Enable Rails/Validation Rubocop cop

Cop checks for the use of old-style attribute validation. Supports autocorrection which was run
to fix the files concerned

Closes #1414
This commit is contained in:
Emanuel Hayford 2017-03-28 21:47:17 +02:00
parent e2a7e396a2
commit e5587d42a2
11 changed files with 33 additions and 46 deletions

View file

@ -1,7 +1,7 @@
class Comment < ActiveRecord::Base
acts_as_nested_set scope: [:commentable_id, :commentable_type]
validates_presence_of :body
validates_presence_of :user
acts_as_nested_set scope: %i(commentable_id commentable_type)
validates :body, presence: true
validates :user, presence: true
after_create :send_notification
# NOTE: install the acts_as_votable plugin if you
@ -13,7 +13,7 @@ class Comment < ActiveRecord::Base
# NOTE: Comments belong to a user
belongs_to :user
has_paper_trail on: [:create, :destroy], meta: { conference_id: :conference_id }
has_paper_trail on: %i(create destroy), meta: { conference_id: :conference_id }
# Helper class method that allows you to build a comment
# by passing a commentable object, a user_id, and comment text