diff options
Diffstat (limited to 'activemodel/test/models')
-rw-r--r-- | activemodel/test/models/automobile.rb | 12 | ||||
-rw-r--r-- | activemodel/test/models/contact.rb | 15 | ||||
-rw-r--r-- | activemodel/test/models/oauthed_user.rb | 11 | ||||
-rw-r--r-- | activemodel/test/models/user.rb | 3 | ||||
-rw-r--r-- | activemodel/test/models/visitor.rb | 1 |
5 files changed, 16 insertions, 26 deletions
diff --git a/activemodel/test/models/automobile.rb b/activemodel/test/models/automobile.rb deleted file mode 100644 index ece644c40c..0000000000 --- a/activemodel/test/models/automobile.rb +++ /dev/null @@ -1,12 +0,0 @@ -class Automobile - include ActiveModel::Validations - - validate :validations - - attr_accessor :make, :model - - def validations - validates_presence_of :make - validates_length_of :model, within: 2..10 - end -end diff --git a/activemodel/test/models/contact.rb b/activemodel/test/models/contact.rb index c25be28e1d..bcfd267a34 100644 --- a/activemodel/test/models/contact.rb +++ b/activemodel/test/models/contact.rb @@ -1,8 +1,13 @@ class Contact extend ActiveModel::Naming include ActiveModel::Conversion + include ActiveModel::Validations + + include ActiveModel::Serializers::JSON + include ActiveModel::Serializers::Xml attr_accessor :id, :name, :age, :created_at, :awesome, :preferences + attr_accessor :address, :friends, :contact def social %w(twitter github) @@ -23,4 +28,14 @@ class Contact def persisted? id end + + def attributes=(hash) + hash.each do |k, v| + instance_variable_set("@#{k}", v) + end + end + + def attributes + instance_values.except("address", "friends", "contact") + end end diff --git a/activemodel/test/models/oauthed_user.rb b/activemodel/test/models/oauthed_user.rb deleted file mode 100644 index 9750bc19d4..0000000000 --- a/activemodel/test/models/oauthed_user.rb +++ /dev/null @@ -1,11 +0,0 @@ -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 diff --git a/activemodel/test/models/user.rb b/activemodel/test/models/user.rb index 4b11df12bf..1ec6001c48 100644 --- a/activemodel/test/models/user.rb +++ b/activemodel/test/models/user.rb @@ -1,11 +1,10 @@ class User extend ActiveModel::Callbacks - include ActiveModel::Validations include ActiveModel::SecurePassword define_model_callbacks :create has_secure_password - attr_accessor :password_digest, :password_salt + attr_accessor :password_digest end diff --git a/activemodel/test/models/visitor.rb b/activemodel/test/models/visitor.rb index 4d7f4be097..22ad1a3c3d 100644 --- a/activemodel/test/models/visitor.rb +++ b/activemodel/test/models/visitor.rb @@ -1,6 +1,5 @@ class Visitor extend ActiveModel::Callbacks - include ActiveModel::Validations include ActiveModel::SecurePassword define_model_callbacks :create |