mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Move test models into their own file so they can be used elsewhere
This commit is contained in:
parent
2be9fb292e
commit
77ec1b08cd
4 changed files with 34 additions and 22 deletions
|
@ -1,4 +1,5 @@
|
|||
require 'test_helper'
|
||||
require 'test_models'
|
||||
require 'digest/sha1'
|
||||
|
||||
class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
||||
|
|
|
@ -1,26 +1,5 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Configurable < User
|
||||
devise :database_authenticatable, :confirmable, :rememberable, :timeoutable, :lockable,
|
||||
:stretches => 15, :pepper => 'abcdef', :allow_unconfirmed_access_for => 5.days,
|
||||
:remember_for => 7.days, :timeout_in => 15.minutes, :unlock_in => 10.days
|
||||
end
|
||||
|
||||
class WithValidation < Admin
|
||||
devise :database_authenticatable, :validatable, :password_length => 2..6
|
||||
end
|
||||
|
||||
class UserWithValidation < User
|
||||
validates_presence_of :username
|
||||
end
|
||||
|
||||
class Several < Admin
|
||||
devise :validatable
|
||||
devise :lockable
|
||||
end
|
||||
|
||||
class Inheritable < Admin
|
||||
end
|
||||
require 'test_models'
|
||||
|
||||
class ActiveRecordTest < ActiveSupport::TestCase
|
||||
def include_module?(klass, mod)
|
||||
|
|
|
@ -29,6 +29,10 @@ class ActiveSupport::TestCase
|
|||
:password_confirmation => '12345678' }.update(attributes)
|
||||
end
|
||||
|
||||
def new_user_with_class(klass=User, attributes={})
|
||||
klass.new(valid_attributes(attributes))
|
||||
end
|
||||
|
||||
def new_user(attributes={})
|
||||
User.new(valid_attributes(attributes))
|
||||
end
|
||||
|
|
28
test/test_models.rb
Normal file
28
test/test_models.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
class Configurable < User
|
||||
devise :database_authenticatable, :confirmable, :rememberable, :timeoutable, :lockable,
|
||||
:stretches => 15, :pepper => 'abcdef', :allow_unconfirmed_access_for => 5.days,
|
||||
:remember_for => 7.days, :timeout_in => 15.minutes, :unlock_in => 10.days
|
||||
end
|
||||
|
||||
class WithValidation < Admin
|
||||
devise :database_authenticatable, :validatable, :password_length => 2..6
|
||||
end
|
||||
|
||||
class UserWithValidation < User
|
||||
validates_presence_of :username
|
||||
end
|
||||
|
||||
class UserWithVirtualAttributes < User
|
||||
devise :case_insensitive_keys => [ :email, :email_confirmation ]
|
||||
validates :email, :presence => true, :confirmation => {:on => :create}
|
||||
attr_accessible :email, :email_confirmation
|
||||
end
|
||||
|
||||
class Several < Admin
|
||||
devise :validatable
|
||||
devise :lockable
|
||||
end
|
||||
|
||||
class Inheritable < Admin
|
||||
end
|
||||
|
Loading…
Add table
Reference in a new issue