diff options
Diffstat (limited to 'activemodel/test/models')
-rw-r--r-- | activemodel/test/models/administrator.rb | 10 | ||||
-rw-r--r-- | activemodel/test/models/person.rb | 7 | ||||
-rw-r--r-- | activemodel/test/models/topic.rb | 12 | ||||
-rw-r--r-- | activemodel/test/models/user.rb | 8 | ||||
-rw-r--r-- | activemodel/test/models/visitor.rb | 9 |
5 files changed, 42 insertions, 4 deletions
diff --git a/activemodel/test/models/administrator.rb b/activemodel/test/models/administrator.rb new file mode 100644 index 0000000000..a48f8b064f --- /dev/null +++ b/activemodel/test/models/administrator.rb @@ -0,0 +1,10 @@ +class Administrator + include ActiveModel::Validations + include ActiveModel::SecurePassword + include ActiveModel::MassAssignmentSecurity + + attr_accessor :name, :password_digest + attr_accessible :name + + has_secure_password +end diff --git a/activemodel/test/models/person.rb b/activemodel/test/models/person.rb index eb84f7a27d..e896e90f98 100644 --- a/activemodel/test/models/person.rb +++ b/activemodel/test/models/person.rb @@ -9,10 +9,9 @@ class Person end end -class Child < Person +class Person::Gender + extend ActiveModel::Translation end -module PersonModule - class Person < ::Person - end +class Child < Person end diff --git a/activemodel/test/models/topic.rb b/activemodel/test/models/topic.rb index ff34565bdb..c9af78f595 100644 --- a/activemodel/test/models/topic.rb +++ b/activemodel/test/models/topic.rb @@ -2,6 +2,10 @@ class Topic include ActiveModel::Validations include ActiveModel::Validations::Callbacks + def self._validates_default_keys + super | [ :message ] + end + attr_accessor :title, :author_name, :content, :approved attr_accessor :after_validation_performed @@ -25,4 +29,12 @@ class Topic self.after_validation_performed = true end + def my_validation + errors.add :title, "is missing" unless title + end + + def my_validation_with_arg(attr) + errors.add attr, "is missing" unless send(attr) + end + end diff --git a/activemodel/test/models/user.rb b/activemodel/test/models/user.rb new file mode 100644 index 0000000000..e221bb8091 --- /dev/null +++ b/activemodel/test/models/user.rb @@ -0,0 +1,8 @@ +class User + include ActiveModel::Validations + include ActiveModel::SecurePassword + + has_secure_password + + attr_accessor :password_digest, :password_salt +end diff --git a/activemodel/test/models/visitor.rb b/activemodel/test/models/visitor.rb new file mode 100644 index 0000000000..36c0a16688 --- /dev/null +++ b/activemodel/test/models/visitor.rb @@ -0,0 +1,9 @@ +class Visitor + include ActiveModel::Validations + include ActiveModel::SecurePassword + include ActiveModel::MassAssignmentSecurity + + has_secure_password + + attr_accessor :password_digest +end |