1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00

Move uniqueness validation to ActiveRecord module

This commit is contained in:
Elliot Winkler 2014-12-08 11:15:46 -07:00
parent b84ec8cc16
commit cf76d747ee
11 changed files with 26 additions and 26 deletions

View file

@ -26,8 +26,6 @@ complex, and error-prone.
tests usage of `validates_numericality_of`.
* **[validate_presence_of](lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb)**
tests usage of `validates_presence_of`.
* **[validate_uniqueness_of](lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb)**
tests usage of `validates_uniqueness_of`.
### ActiveRecord Matchers
@ -51,6 +49,8 @@ complex, and error-prone.
tests usage of the `attr_readonly` macro.
* **[serialize](lib/shoulda/matchers/active_record/serialize_matcher.rb)** tests
usage of the `serialize` macro.
* **[validate_uniqueness_of](lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb)**
tests usage of `validates_uniqueness_of`.
### ActionController Matchers

View file

@ -1,5 +1,4 @@
require 'shoulda/matchers/active_model/helpers'
require 'shoulda/matchers/active_model/uniqueness'
require 'shoulda/matchers/active_model/validation_matcher'
require 'shoulda/matchers/active_model/validation_message_finder'
require 'shoulda/matchers/active_model/exception_message_finder'
@ -10,7 +9,6 @@ require 'shoulda/matchers/active_model/validate_inclusion_of_matcher'
require 'shoulda/matchers/active_model/validate_exclusion_of_matcher'
require 'shoulda/matchers/active_model/validate_absence_of_matcher'
require 'shoulda/matchers/active_model/validate_presence_of_matcher'
require 'shoulda/matchers/active_model/validate_uniqueness_of_matcher'
require 'shoulda/matchers/active_model/validate_acceptance_of_matcher'
require 'shoulda/matchers/active_model/validate_confirmation_of_matcher'
require 'shoulda/matchers/active_model/validate_numericality_of_matcher'

View file

@ -1,14 +0,0 @@
module Shoulda
module Matchers
module ActiveModel
# @private
module Uniqueness
end
end
end
end
require 'shoulda/matchers/active_model/uniqueness/model'
require 'shoulda/matchers/active_model/uniqueness/namespace'
require 'shoulda/matchers/active_model/uniqueness/test_model_creator'
require 'shoulda/matchers/active_model/uniqueness/test_models'

View file

@ -16,6 +16,8 @@ require "shoulda/matchers/active_record/have_readonly_attribute_matcher"
require "shoulda/matchers/active_record/serialize_matcher"
require "shoulda/matchers/active_record/accept_nested_attributes_for_matcher"
require "shoulda/matchers/active_record/define_enum_for_matcher"
require "shoulda/matchers/active_record/uniqueness"
require "shoulda/matchers/active_record/validate_uniqueness_of_matcher"
module Shoulda
module Matchers

View file

@ -0,0 +1,14 @@
module Shoulda
module Matchers
module ActiveModel
# @private
module Uniqueness
end
end
end
end
require 'shoulda/matchers/active_record/uniqueness/model'
require 'shoulda/matchers/active_record/uniqueness/namespace'
require 'shoulda/matchers/active_record/uniqueness/test_model_creator'
require 'shoulda/matchers/active_record/uniqueness/test_models'

View file

@ -1,6 +1,6 @@
module Shoulda
module Matchers
module ActiveModel
module ActiveRecord
module Uniqueness
# @private
class Model

View file

@ -1,6 +1,6 @@
module Shoulda
module Matchers
module ActiveModel
module ActiveRecord
module Uniqueness
# @private
class Namespace

View file

@ -2,7 +2,7 @@ require 'thread'
module Shoulda
module Matchers
module ActiveModel
module ActiveRecord
module Uniqueness
# @private
class TestModelCreator

View file

@ -2,7 +2,7 @@ require 'thread'
module Shoulda
module Matchers
module ActiveModel
module ActiveRecord
module Uniqueness
# @private
module TestModels

View file

@ -1,6 +1,6 @@
module Shoulda
module Matchers
module ActiveModel
module ActiveRecord
# The `validate_uniqueness_of` matcher tests usage of the
# `validates_uniqueness_of` validation. It first checks for an existing
# instance of your model in the database, creating one if necessary. It
@ -196,8 +196,8 @@ module Shoulda
end
# @private
class ValidateUniquenessOfMatcher < ValidationMatcher
include Helpers
class ValidateUniquenessOfMatcher < ActiveModel::ValidationMatcher
include ActiveModel::Helpers
def initialize(attribute)
super(attribute)

View file

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::ValidateUniquenessOfMatcher do
describe Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher do
context 'a model without a a uniqueness validation' do
it 'rejects' do
model = define_model(:example, attr: :string) { attr_accessible :attr } .new