aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/models
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/test/models')
-rw-r--r--activemodel/test/models/account.rb5
-rw-r--r--activemodel/test/models/administrator.rb5
-rw-r--r--activemodel/test/models/mass_assignment_specific.rb76
-rw-r--r--activemodel/test/models/oauthed_user.rb11
-rw-r--r--activemodel/test/models/project.rb3
-rw-r--r--activemodel/test/models/user.rb3
-rw-r--r--activemodel/test/models/visitor.rb8
7 files changed, 30 insertions, 81 deletions
diff --git a/activemodel/test/models/account.rb b/activemodel/test/models/account.rb
new file mode 100644
index 0000000000..eed668d38f
--- /dev/null
+++ b/activemodel/test/models/account.rb
@@ -0,0 +1,5 @@
+class Account
+ include ActiveModel::ForbiddenAttributesProtection
+
+ public :sanitize_for_mass_assignment
+end
diff --git a/activemodel/test/models/administrator.rb b/activemodel/test/models/administrator.rb
index a48f8b064f..2f3aff290c 100644
--- a/activemodel/test/models/administrator.rb
+++ b/activemodel/test/models/administrator.rb
@@ -1,10 +1,11 @@
class Administrator
+ extend ActiveModel::Callbacks
include ActiveModel::Validations
include ActiveModel::SecurePassword
- include ActiveModel::MassAssignmentSecurity
+
+ define_model_callbacks :create
attr_accessor :name, :password_digest
- attr_accessible :name
has_secure_password
end
diff --git a/activemodel/test/models/mass_assignment_specific.rb b/activemodel/test/models/mass_assignment_specific.rb
deleted file mode 100644
index 1d123fa58c..0000000000
--- a/activemodel/test/models/mass_assignment_specific.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-class User
- include ActiveModel::MassAssignmentSecurity
- attr_protected :admin
-
- public :sanitize_for_mass_assignment
-end
-
-class SpecialUser
- include ActiveModel::MassAssignmentSecurity
- attr_accessible :name, :email, :as => :moderator
-
- public :sanitize_for_mass_assignment
-end
-
-class Person
- include ActiveModel::MassAssignmentSecurity
- attr_accessible :name, :email
- attr_accessible :name, :email, :admin, :as => :admin
-
- public :sanitize_for_mass_assignment
-end
-
-class Account
- include ActiveModel::MassAssignmentSecurity
- attr_accessible :name, :email, :as => [:default, :admin]
- attr_accessible :admin, :as => :admin
-
- public :sanitize_for_mass_assignment
-end
-
-class Firm
- include ActiveModel::MassAssignmentSecurity
-
- public :sanitize_for_mass_assignment
-
- def self.attributes_protected_by_default
- ["type"]
- end
-end
-
-class Task
- include ActiveModel::MassAssignmentSecurity
- attr_protected :starting
-
- public :sanitize_for_mass_assignment
-end
-
-class LoosePerson
- include ActiveModel::MassAssignmentSecurity
- attr_protected :credit_rating, :administrator
- attr_protected :credit_rating, :as => :admin
-end
-
-class LooseDescendant < LoosePerson
- attr_protected :phone_number
-end
-
-class LooseDescendantSecond< LoosePerson
- attr_protected :phone_number
- attr_protected :name
-end
-
-class TightPerson
- include ActiveModel::MassAssignmentSecurity
- attr_accessible :name, :address
- attr_accessible :name, :address, :admin, :as => :admin
-
- def self.attributes_protected_by_default
- ["mobile_number"]
- end
-end
-
-class TightDescendant < TightPerson
- attr_accessible :phone_number
- attr_accessible :super_powers, :as => :admin
-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
diff --git a/activemodel/test/models/project.rb b/activemodel/test/models/project.rb
new file mode 100644
index 0000000000..581b6dc0b3
--- /dev/null
+++ b/activemodel/test/models/project.rb
@@ -0,0 +1,3 @@
+class Project
+ include ActiveModel::DeprecatedMassAssignmentSecurity
+end
diff --git a/activemodel/test/models/user.rb b/activemodel/test/models/user.rb
index e221bb8091..4b11df12bf 100644
--- a/activemodel/test/models/user.rb
+++ b/activemodel/test/models/user.rb
@@ -1,6 +1,9 @@
class User
+ extend ActiveModel::Callbacks
include ActiveModel::Validations
include ActiveModel::SecurePassword
+
+ define_model_callbacks :create
has_secure_password
diff --git a/activemodel/test/models/visitor.rb b/activemodel/test/models/visitor.rb
index 36c0a16688..4d7f4be097 100644
--- a/activemodel/test/models/visitor.rb
+++ b/activemodel/test/models/visitor.rb
@@ -1,9 +1,11 @@
class Visitor
+ extend ActiveModel::Callbacks
include ActiveModel::Validations
include ActiveModel::SecurePassword
- include ActiveModel::MassAssignmentSecurity
- has_secure_password
+ define_model_callbacks :create
- attr_accessor :password_digest
+ has_secure_password(validations: false)
+
+ attr_accessor :password_digest, :password_confirmation
end