diff options
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/lib/active_model.rb | 1 | ||||
-rw-r--r-- | activemodel/lib/active_model/attribute_methods.rb | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/conversion.rb | 1 | ||||
-rw-r--r-- | activemodel/lib/active_model/dirty.rb | 1 | ||||
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 1 | ||||
-rw-r--r-- | activemodel/lib/active_model/mass_assignment_security.rb | 1 | ||||
-rw-r--r-- | activemodel/lib/active_model/naming.rb | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/observing.rb | 3 | ||||
-rw-r--r-- | activemodel/lib/active_model/secure_password.rb | 4 | ||||
-rw-r--r-- | activemodel/lib/active_model/serializers/json.rb | 1 | ||||
-rw-r--r-- | activemodel/lib/active_model/validations.rb | 1 | ||||
-rw-r--r-- | activemodel/lib/active_model/validations/presence.rb | 1 | ||||
-rw-r--r-- | activemodel/lib/active_model/validator.rb | 2 | ||||
-rw-r--r-- | activemodel/test/cases/mass_assignment_security/sanitizer_test.rb | 1 | ||||
-rw-r--r-- | activemodel/test/cases/secure_password_test.rb | 8 | ||||
-rw-r--r-- | activemodel/test/models/oauthed_user.rb | 11 |
16 files changed, 23 insertions, 18 deletions
diff --git a/activemodel/lib/active_model.rb b/activemodel/lib/active_model.rb index f6bacf5ec0..ec2d734647 100644 --- a/activemodel/lib/active_model.rb +++ b/activemodel/lib/active_model.rb @@ -22,6 +22,7 @@ #++ require 'active_support' +require 'active_support/rails' require 'active_model/version' module ActiveModel diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb index eb06250060..21b1209875 100644 --- a/activemodel/lib/active_model/attribute_methods.rb +++ b/activemodel/lib/active_model/attribute_methods.rb @@ -1,5 +1,3 @@ -require 'active_support/core_ext/class/attribute' -require 'active_support/deprecation' module ActiveModel # Raised when an attribute is not defined. diff --git a/activemodel/lib/active_model/conversion.rb b/activemodel/lib/active_model/conversion.rb index 57b1bc2ada..48c53f0789 100644 --- a/activemodel/lib/active_model/conversion.rb +++ b/activemodel/lib/active_model/conversion.rb @@ -1,4 +1,3 @@ -require 'active_support/concern' require 'active_support/inflector' module ActiveModel diff --git a/activemodel/lib/active_model/dirty.rb b/activemodel/lib/active_model/dirty.rb index 9bd5f903cd..c0b268fa4d 100644 --- a/activemodel/lib/active_model/dirty.rb +++ b/activemodel/lib/active_model/dirty.rb @@ -1,7 +1,6 @@ require 'active_model/attribute_methods' require 'active_support/hash_with_indifferent_access' require 'active_support/core_ext/object/duplicable' -require 'active_support/core_ext/object/blank' module ActiveModel # == Active Model Dirty diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 4ed3462e7e..d68086584e 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -2,7 +2,6 @@ require 'active_support/core_ext/array/conversions' require 'active_support/core_ext/string/inflections' -require 'active_support/core_ext/object/blank' module ActiveModel # == Active Model Errors diff --git a/activemodel/lib/active_model/mass_assignment_security.rb b/activemodel/lib/active_model/mass_assignment_security.rb index e57fcf1610..87c0bcf59b 100644 --- a/activemodel/lib/active_model/mass_assignment_security.rb +++ b/activemodel/lib/active_model/mass_assignment_security.rb @@ -1,4 +1,3 @@ -require 'active_support/core_ext/class/attribute' require 'active_support/core_ext/string/inflections' require 'active_model/mass_assignment_security/permission_set' require 'active_model/mass_assignment_security/sanitizer' diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb index ea4f9341c6..af89391413 100644 --- a/activemodel/lib/active_model/naming.rb +++ b/activemodel/lib/active_model/naming.rb @@ -1,8 +1,6 @@ require 'active_support/inflector' require 'active_support/core_ext/hash/except' require 'active_support/core_ext/module/introspection' -require 'active_support/core_ext/module/delegation' -require 'active_support/core_ext/object/blank' module ActiveModel class Name diff --git a/activemodel/lib/active_model/observing.rb b/activemodel/lib/active_model/observing.rb index 976dcf23d8..acc96ddc9f 100644 --- a/activemodel/lib/active_model/observing.rb +++ b/activemodel/lib/active_model/observing.rb @@ -4,7 +4,6 @@ require 'active_support/core_ext/module/aliasing' require 'active_support/core_ext/module/remove_method' require 'active_support/core_ext/string/inflections' require 'active_support/core_ext/enumerable' -require 'active_support/deprecation' require 'active_support/core_ext/object/try' require 'active_support/descendants_tracker' @@ -215,7 +214,7 @@ module ActiveModel # end # end def observed_classes - [observed_class].compact.flatten + Array(observed_class) end # The class observed by default is inferred from the observer's class name: diff --git a/activemodel/lib/active_model/secure_password.rb b/activemodel/lib/active_model/secure_password.rb index 3eab745c89..dc89efd2d1 100644 --- a/activemodel/lib/active_model/secure_password.rb +++ b/activemodel/lib/active_model/secure_password.rb @@ -43,9 +43,9 @@ module ActiveModel if options.fetch(:validations, true) validates_confirmation_of :password validates_presence_of :password, :on => :create + + before_create { raise "Password digest missing on new record" if password_digest.blank? } end - - before_create { raise "Password digest missing on new record" if password_digest.blank? } include InstanceMethodsOnActivation diff --git a/activemodel/lib/active_model/serializers/json.rb b/activemodel/lib/active_model/serializers/json.rb index e4c7553cb8..eaea0475ad 100644 --- a/activemodel/lib/active_model/serializers/json.rb +++ b/activemodel/lib/active_model/serializers/json.rb @@ -1,5 +1,4 @@ require 'active_support/json' -require 'active_support/core_ext/class/attribute' module ActiveModel # == Active Model JSON Serializer diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index 55ea6be796..5ae3a97c6b 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -1,5 +1,4 @@ require 'active_support/core_ext/array/extract_options' -require 'active_support/core_ext/class/attribute' require 'active_support/core_ext/hash/keys' require 'active_support/core_ext/hash/except' require 'active_model/errors' diff --git a/activemodel/lib/active_model/validations/presence.rb b/activemodel/lib/active_model/validations/presence.rb index 4592a1deb0..f159e40858 100644 --- a/activemodel/lib/active_model/validations/presence.rb +++ b/activemodel/lib/active_model/validations/presence.rb @@ -1,4 +1,3 @@ -require 'active_support/core_ext/object/blank' module ActiveModel diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index d5d0798704..cbbf58505b 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/activemodel/lib/active_model/validator.rb @@ -1,6 +1,4 @@ require "active_support/core_ext/module/anonymous" -require 'active_support/core_ext/object/blank' -require 'active_support/core_ext/object/inclusion' module ActiveModel #:nodoc: diff --git a/activemodel/test/cases/mass_assignment_security/sanitizer_test.rb b/activemodel/test/cases/mass_assignment_security/sanitizer_test.rb index 418a24294a..b141cec059 100644 --- a/activemodel/test/cases/mass_assignment_security/sanitizer_test.rb +++ b/activemodel/test/cases/mass_assignment_security/sanitizer_test.rb @@ -1,6 +1,5 @@ require "cases/helper" require 'active_support/logger' -require 'active_support/core_ext/object/inclusion' class SanitizerTest < ActiveModel::TestCase attr_accessor :logger diff --git a/activemodel/test/cases/secure_password_test.rb b/activemodel/test/cases/secure_password_test.rb index 5f18909301..8650b0e495 100644 --- a/activemodel/test/cases/secure_password_test.rb +++ b/activemodel/test/cases/secure_password_test.rb @@ -1,5 +1,6 @@ require 'cases/helper' require 'models/user' +require 'models/oauthed_user' require 'models/visitor' require 'models/administrator' @@ -8,6 +9,7 @@ class SecurePasswordTest < ActiveModel::TestCase setup do @user = User.new @visitor = Visitor.new + @oauthed_user = OauthedUser.new end test "blank password" do @@ -73,4 +75,10 @@ class SecurePasswordTest < ActiveModel::TestCase @user.run_callbacks :create end end + + test "Oauthed user can be created with blank digest" do + assert_nothing_raised do + @oauthed_user.run_callbacks :create + end + end end diff --git a/activemodel/test/models/oauthed_user.rb b/activemodel/test/models/oauthed_user.rb new file mode 100644 index 0000000000..9750bc19d4 --- /dev/null +++ b/activemodel/test/models/oauthed_user.rb @@ -0,0 +1,11 @@ +class OauthedUser + extend ActiveModel::Callbacks + include ActiveModel::Validations + include ActiveModel::SecurePassword + + define_model_callbacks :create + + has_secure_password(validations: false) + + attr_accessor :password_digest, :password_salt +end |