From c0960bd72dd41c4e9bd8b4375254f539776bfe95 Mon Sep 17 00:00:00 2001 From: Nicholas Shirley Date: Sat, 14 Apr 2018 12:20:26 +0200 Subject: [PATCH] update comment examples to use validates format The instances of validates_uniqueness_of are replaced in favor of the newer `validates :attribute, uniqueness: true` format or when case insensitivity is required `validates :attribute, uniqueness: { case_sensitive: false }` Issue ref: #1092 --- .../validate_uniqueness_of_matcher.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb b/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb index 17ef7fc45..163933a0e 100644 --- a/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +++ b/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb @@ -10,7 +10,7 @@ module ActiveRecord # pre-existing record (thereby failing the uniqueness check). # # class Post < ActiveRecord::Base - # validates_uniqueness_of :permalink + # validates :permalink, uniqueness: true # end # # # RSpec @@ -102,7 +102,7 @@ module ActiveRecord # Use `on` if your validation applies only under a certain context. # # class Post < ActiveRecord::Base - # validates_uniqueness_of :title, on: :create + # validates :title, uniqueness: true, on: :create # end # # # RSpec @@ -120,7 +120,7 @@ module ActiveRecord # Use `with_message` if you are using a custom validation message. # # class Post < ActiveRecord::Base - # validates_uniqueness_of :title, message: 'Please choose another title' + # validates :title, uniqueness: true, message: 'Please choose another title' # end # # # RSpec @@ -144,7 +144,7 @@ module ActiveRecord # unique, but the scoped attributes are not unique either. # # class Post < ActiveRecord::Base - # validates_uniqueness_of :slug, scope: :journal_id + # validates :slug, uniqueness: true, scope: :journal_id # end # # # RSpec @@ -165,7 +165,7 @@ module ActiveRecord # attributes in the pre-existing record. # # class Post < ActiveRecord::Base - # validates_uniqueness_of :key, case_sensitive: false + # validates :key, uniqueness: { case_sensitive: false } # end # # # RSpec @@ -193,7 +193,7 @@ module ActiveRecord # attribute. # # class User < ActiveRecord::Base - # validates_uniqueness_of :email + # validates :email, uniqueness: true # # def email=(value) # super(value.downcase) @@ -217,7 +217,7 @@ module ActiveRecord # Use `allow_nil` to assert that the attribute allows nil. # # class Post < ActiveRecord::Base - # validates_uniqueness_of :author_id, allow_nil: true + # validates :author_id, uniqueness: true, allow_nil: true # end # # # RSpec @@ -237,7 +237,7 @@ module ActiveRecord # Use `allow_blank` to assert that the attribute allows a blank value. # # class Post < ActiveRecord::Base - # validates_uniqueness_of :author_id, allow_blank: true + # validates :author_id, uniqueness: true, allow_blank: true # end # # # RSpec