devise 0.5.6 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of devise might be problematic. Click here for more details.

@@ -1,3 +1,14 @@
1
+ == 0.6.0
2
+
3
+ * deprecations
4
+ * :authenticatable is not included by default anymore
5
+
6
+ * enhancements
7
+ * Added DataMapper support
8
+ * Remove store_location from authenticatable strategy and add it to failure app
9
+ * Allow a strategy to be placed after authenticatable
10
+ * [#45] Do not rely attribute? methods, since they are not added on Datamapper
11
+
1
12
  == 0.5.6
2
13
 
3
14
  * enhancements
@@ -74,7 +74,7 @@ This line adds devise authenticatable automatically for you inside your User cla
74
74
 
75
75
  You could also include the other devise modules as below:
76
76
 
77
- # Same as using only devise, authenticatable is activated by default
77
+ # Include only authenticatable stuff
78
78
  devise :authenticatable
79
79
 
80
80
  # Include authenticatable + confirmable
@@ -150,7 +150,7 @@ Devise let's you setup as many roles as you want, so let's say you already have
150
150
  end
151
151
 
152
152
  # Inside your Admin model
153
- devise :validatable
153
+ devise :authenticatable, :validatable
154
154
 
155
155
  # Inside your routes
156
156
  map.devise_for :admin
data/TODO CHANGED
@@ -1,3 +1,5 @@
1
+ * Create update_with_password
2
+ * Make test run with different ORMs
1
3
  * Devise::Timeoutable
2
4
  * Use request_ip in session cookies
3
5
  * Devise::BruteForceProtection
@@ -37,7 +37,7 @@ Devise.setup do |config|
37
37
  # Configure the e-mail address which will be shown in DeviseMailer.
38
38
  # config.mailer_sender = "foo.bar@yourapp.com"
39
39
 
40
- # Configure the ORM. Supports :active_record and :mongo_mapper
40
+ # Configure the ORM. Supports :active_record, :data_mapper and :mongo_mapper.
41
41
  # config.orm = :active_record
42
42
 
43
43
  # Turn scoped views on. Before rendering "sessions/new", it will first check for
@@ -46,15 +46,8 @@ module Devise
46
46
  @@confirm_within = 0.days
47
47
 
48
48
  # Used to define the password encryption algorithm.
49
- def self.encryptor=(value)
50
- @@encryptor = if value.is_a?(Symbol)
51
- ::Devise::Encryptors.const_get(value.to_s.classify)
52
- else
53
- value
54
- end
55
- end
56
- mattr_reader :encryptor
57
- @@encryptor = ::Devise::Encryptors::Sha1
49
+ mattr_accessor :encryptor
50
+ @@encryptor = :sha1
58
51
 
59
52
  # Store scopes mappings.
60
53
  mattr_accessor :mappings
@@ -1,31 +1,34 @@
1
1
  module Devise
2
- module FailureApp
3
- mattr_accessor :default_url
2
+ # Failure application that will be called every time :warden is thrown from
3
+ # any strategy or hook. Responsible for redirect the user to the sign in
4
+ # page based on current scope and mapping. If no scope is given, redirect
5
+ # to the default_url.
6
+ class FailureApp
7
+ attr_reader :env
8
+ include Warden::Mixins::Common
9
+
10
+ cattr_accessor :default_url, :default_message, :instance_writer => false
11
+ @@default_message = :unauthenticated
4
12
 
5
- # Failure application that will be called every time :warden is thrown from
6
- # any strategy or hook. Responsible for redirect the user to the sign in
7
- # page based on current scope and mapping. If no scope is given, redirect
8
- # to the default_url.
9
13
  def self.call(env)
10
- options = env['warden.options']
11
- scope = options[:scope]
12
- message = env['warden'].try(:message) || options[:message]
14
+ new(env).respond!
15
+ end
13
16
 
14
- params = case message
15
- when Symbol
16
- { message => true }
17
- when String
18
- { :message => message }
19
- else
20
- {}
21
- end
17
+ def initialize(env)
18
+ @env = env
19
+ end
20
+
21
+ def respond!
22
+ options = @env['warden.options']
23
+ scope = options[:scope]
22
24
 
23
25
  redirect_path = if mapping = Devise.mappings[scope]
24
26
  "#{mapping.parsed_path}/#{mapping.path_names[:sign_in]}"
25
27
  else
26
28
  "/#{default_url}"
27
29
  end
28
- query_string = Rack::Utils.build_query(params)
30
+ query_string = query_string_for(options)
31
+ store_location!(scope)
29
32
 
30
33
  headers = {}
31
34
  headers["Location"] = redirect_path
@@ -34,5 +37,29 @@ module Devise
34
37
 
35
38
  [302, headers, ["You are being redirected to #{redirect_path}"]]
36
39
  end
40
+
41
+ # Build the proper query string based on the given message.
42
+ def query_string_for(options)
43
+ message = @env['warden'].try(:message) || options[:message] || default_message
44
+
45
+ params = case message
46
+ when Symbol
47
+ { message => true }
48
+ when String
49
+ { :message => message }
50
+ else
51
+ {}
52
+ end
53
+
54
+ Rack::Utils.build_query(params)
55
+ end
56
+
57
+ # Stores requested uri to redirect the user after signing in. We cannot use
58
+ # scoped session provided by warden here, since the user is not authenticated
59
+ # yet, but we still need to store the uri based on scope, so different scopes
60
+ # would never use the same uri to redirect.
61
+ def store_location!(scope)
62
+ session[:"#{scope}.return_to"] ||= request.request_uri if request && request.get?
63
+ end
37
64
  end
38
65
  end
@@ -19,12 +19,6 @@ module Devise
19
19
  def self.config(mod, *accessors) #:nodoc:
20
20
  accessors.each do |accessor|
21
21
  mod.class_eval <<-METHOD, __FILE__, __LINE__
22
- def #{accessor}
23
- self.class.#{accessor}
24
- end
25
- METHOD
26
-
27
- mod.const_get(:ClassMethods).class_eval <<-METHOD, __FILE__, __LINE__
28
22
  def #{accessor}
29
23
  if defined?(@#{accessor})
30
24
  @#{accessor}
@@ -56,47 +50,45 @@ module Devise
56
50
  #
57
51
  # Examples:
58
52
  #
59
- # # include only authenticatable module (default)
60
- # devise
53
+ # # include only authenticatable module
54
+ # devise :authenticatable
61
55
  #
62
56
  # # include authenticatable + confirmable modules
63
- # devise :confirmable
57
+ # devise :authenticatable, :confirmable
64
58
  #
65
59
  # # include authenticatable + recoverable modules
66
- # devise :recoverable
67
- #
68
- # # include authenticatable + rememberable modules
69
- # devise :rememberable
60
+ # devise :authenticatable, :recoverable
70
61
  #
71
- # # include authenticatable + validatable modules
72
- # devise :validatable
62
+ # # include authenticatable + rememberable + validatable modules
63
+ # devise :authenticatable, :rememberable, :validatable
73
64
  #
74
- # # include authenticatable + confirmable + recoverable + rememberable + validatable
75
- # devise :confirmable, :recoverable, :rememberable, :validatable
76
- #
77
- # # shortcut to include all modules (same as above)
65
+ # # shortcut to include all available modules
78
66
  # devise :all
79
67
  #
80
68
  # # include all except recoverable
81
69
  # devise :all, :except => :recoverable
82
70
  #
83
71
  def devise(*modules)
84
- options = modules.extract_options!
72
+ # TODO Add this check in future versions
73
+ # raise "You need to give at least one Devise module" if modules.empty?
85
74
 
75
+ options = modules.extract_options!
86
76
  modules = Devise.all if modules.include?(:all)
87
77
  modules -= Array(options.delete(:except))
88
- modules = [:authenticatable] | modules
89
78
 
90
- modules.each do |m|
91
- devise_modules << m.to_sym
92
- include Devise::Models.const_get(m.to_s.classify)
79
+ if !modules.include?(:authenticatable)
80
+ modules = [:authenticatable] | modules
81
+ ActiveSupport::Deprecation.warn ":authenticatable won't be included by default in devise in future versions, please add it", caller[0,10]
93
82
  end
94
83
 
95
- # Convert new keys to methods which overwrites Devise defaults
96
- options.each { |key, value| send(:"#{key}=", value) }
84
+ Devise.orm_class.included_modules_hook(self, modules) do
85
+ modules.each do |m|
86
+ devise_modules << m.to_sym
87
+ include Devise::Models.const_get(m.to_s.classify)
88
+ end
97
89
 
98
- # Call specific hooks for each ORM
99
- Devise.orm_class.included_modules_hook(self, devise_modules)
90
+ options.each { |key, value| send(:"#{key}=", value) }
91
+ end
100
92
  end
101
93
 
102
94
  # Stores all modules included inside the model, so we are able to verify
@@ -54,9 +54,9 @@ module Devise
54
54
 
55
55
  protected
56
56
 
57
- # Digests the password using the configured encryptor
57
+ # Digests the password using the configured encryptor.
58
58
  def password_digest(password)
59
- encryptor.digest(password, stretches, password_salt, pepper)
59
+ self.class.encryptor_class.digest(password, self.class.stretches, password_salt, self.class.pepper)
60
60
  end
61
61
 
62
62
  module ClassMethods
@@ -87,11 +87,10 @@ module Devise
87
87
  # Attempt to find a user by it's email. If not user is found, returns a
88
88
  # new user with an email not found error.
89
89
  def find_or_initialize_with_error_by_email(email)
90
- perishable = find_or_initialize_by_email(email)
91
- if perishable.new_record?
92
- perishable.errors.add(:email, :not_found, :default => 'not found')
93
- end
94
- perishable
90
+ attributes = { :email => email }
91
+ record = find(:first, :conditions => attributes) || new(attributes)
92
+ record.errors.add(:email, :not_found, :default => 'not found') if record.new_record?
93
+ record
95
94
  end
96
95
 
97
96
  # Hook to serialize user into session. Overwrite if you want.
@@ -103,11 +102,16 @@ module Devise
103
102
  def serialize_from_session(keys)
104
103
  klass, id = keys
105
104
  raise "#{self} cannot serialize from #{klass} session since it's not its ancestors" unless klass <= self
106
- klass.find_by_id(id)
105
+ klass.find(:first, :conditions => { :id => id })
106
+ end
107
+
108
+ # Returns the class for the configured encryptor.
109
+ def encryptor_class
110
+ @encryptor_class ||= ::Devise::Encryptors.const_get(encryptor.to_s.classify)
107
111
  end
108
- end
109
112
 
110
- Devise::Models.config(self, :pepper, :stretches, :encryptor, :authentication_keys)
113
+ Devise::Models.config(self, :pepper, :stretches, :encryptor, :authentication_keys)
114
+ end
111
115
  end
112
116
  end
113
117
  end
@@ -51,7 +51,7 @@ module Devise
51
51
 
52
52
  # Verifies whether a user is confirmed or not
53
53
  def confirmed?
54
- !new_record? && confirmed_at?
54
+ !new_record? && !confirmed_at.nil?
55
55
  end
56
56
 
57
57
  # Send confirmation instructions by email
@@ -100,8 +100,8 @@ module Devise
100
100
  # confirmation_period_valid? # will always return false
101
101
  #
102
102
  def confirmation_period_valid?
103
- confirmation_sent_at? &&
104
- (Time.now.utc - confirmation_sent_at.utc) < confirm_within
103
+ confirmation_sent_at &&
104
+ ((Time.now.utc - confirmation_sent_at.utc) < self.class.confirm_within)
105
105
  end
106
106
 
107
107
  # Checks whether the record is confirmed or not, yielding to the block
@@ -124,7 +124,6 @@ module Devise
124
124
  end
125
125
 
126
126
  module ClassMethods
127
-
128
127
  # Attempt to find a user by it's email. If a record is found, send new
129
128
  # confirmation instructions to it. If not user is found, returns a new user
130
129
  # with an email not found error.
@@ -148,9 +147,9 @@ module Devise
148
147
  end
149
148
  confirmable
150
149
  end
151
- end
152
150
 
153
- Devise::Models.config(self, :confirm_within)
151
+ Devise::Models.config(self, :confirm_within)
152
+ end
154
153
  end
155
154
  end
156
155
  end
@@ -57,7 +57,6 @@ module Devise
57
57
  end
58
58
 
59
59
  module ClassMethods
60
-
61
60
  # Attempt to find a user by it's email. If a record is found, send new
62
61
  # password instructions to it. If not user is found, returns a new user
63
62
  # with an email not found error.
@@ -51,7 +51,7 @@ module Devise
51
51
  # Removes the remember token only if it exists, and save the record
52
52
  # without validations.
53
53
  def forget_me!
54
- if remember_token?
54
+ if remember_token
55
55
  self.remember_token = nil
56
56
  self.remember_created_at = nil
57
57
  save(false)
@@ -60,7 +60,7 @@ module Devise
60
60
 
61
61
  # Checks whether the incoming token matches or not with the record token.
62
62
  def valid_remember_token?(token)
63
- remember_token? && !remember_expired? && remember_token == token
63
+ remember_token && !remember_expired? && remember_token == token
64
64
  end
65
65
 
66
66
  # Remember token should be expired if expiration time not overpass now.
@@ -70,11 +70,10 @@ module Devise
70
70
 
71
71
  # Remember token expires at created time + remember_for configuration
72
72
  def remember_expires_at
73
- remember_created_at + remember_for
73
+ remember_created_at + self.class.remember_for
74
74
  end
75
75
 
76
76
  module ClassMethods
77
-
78
77
  # Create the cookie key using the record id and remember_token
79
78
  def serialize_into_cookie(rememberable)
80
79
  "#{rememberable.id}::#{rememberable.remember_token}"
@@ -86,9 +85,9 @@ module Devise
86
85
  rememberable = find_by_id(rememberable_id) if rememberable_id
87
86
  rememberable if rememberable.try(:valid_remember_token?, remember_token)
88
87
  end
89
- end
90
88
 
91
- Devise::Models.config(self, :remember_for)
89
+ Devise::Models.config(self, :remember_for)
90
+ end
92
91
  end
93
92
  end
94
93
  end
@@ -17,8 +17,9 @@ module Devise
17
17
  # add_index "accounts", ["reset_password_token"], :name => "reset_password_token", :unique => true
18
18
  #
19
19
  module ActiveRecord
20
- # Required ORM hook. By default, do nothing on ActiveRecord.
20
+ # Required ORM hook. Just yield the given block in ActiveRecord.
21
21
  def self.included_modules_hook(klass, modules)
22
+ yield
22
23
  end
23
24
 
24
25
  include Devise::Schema
@@ -34,4 +35,4 @@ end
34
35
  if defined?(ActiveRecord)
35
36
  ActiveRecord::Base.extend Devise::Models
36
37
  ActiveRecord::ConnectionAdapters::TableDefinition.send :include, Devise::Orm::ActiveRecord
37
- end
38
+ end
@@ -0,0 +1,63 @@
1
+ module Devise
2
+ module Orm
3
+ module DataMapper
4
+ def self.included_modules_hook(klass, modules)
5
+ klass.send :extend, self
6
+ yield
7
+
8
+ # DataMapper validations have a completely different API
9
+ if modules.include?(:validatable) && !klass.respond_to?(:validates_presence_of)
10
+ raise ":validatable is not supported in DataMapper, please craft your validations by hand"
11
+ end
12
+
13
+ modules.each do |mod|
14
+ klass.send(mod) if klass.respond_to?(mod)
15
+ end
16
+ end
17
+
18
+ include Devise::Schema
19
+
20
+ SCHEMA_OPTIONS = {
21
+ :null => :nullable,
22
+ :limit => :length
23
+ }
24
+
25
+ # Hooks for confirmable
26
+ def before_create(*args)
27
+ before :create, *args
28
+ end
29
+
30
+ def after_create(*args)
31
+ after :create, *args
32
+ end
33
+
34
+ # Add ActiveRecord like finder
35
+ def find(*args)
36
+ options = args.extract_options!
37
+ case args.first
38
+ when :first
39
+ first(options.merge(options.delete(:conditions)))
40
+ when :all
41
+ all(options.merge(options.delete(:conditions)))
42
+ else
43
+ get(*args)
44
+ end
45
+ end
46
+
47
+ # Tell how to apply schema methods. This automatically maps :limit to
48
+ # :length and :null to :nullable.
49
+ def apply_schema(name, type, options={})
50
+ return unless Devise.apply_schema
51
+
52
+ SCHEMA_OPTIONS.each do |old_key, new_key|
53
+ next unless options.key?(old_key)
54
+ options[new_key] = options.delete(old_key)
55
+ end
56
+
57
+ property name, type, options
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ DataMapper::Model.send(:include, Devise::Models)
@@ -1,12 +1,12 @@
1
1
  module Devise
2
2
  module Orm
3
3
  module MongoMapper
4
- # Include attributes modules and set the proper ones.
5
4
  def self.included_modules_hook(klass, modules)
6
5
  klass.send :extend, self
6
+ yield
7
7
 
8
8
  modules.each do |mod|
9
- klass.send(mod)
9
+ klass.send(mod) if klass.respond_to?(mod)
10
10
  end
11
11
  end
12
12
 
@@ -42,7 +42,7 @@ module Devise
42
42
  end
43
43
 
44
44
  # Overwrite with specific modification to create your own schema.
45
- def apply_schema(name, tupe, options={})
45
+ def apply_schema(name, type, options={})
46
46
  raise NotImplementedError
47
47
  end
48
48
  end
@@ -12,21 +12,8 @@ module Devise
12
12
  mapping.to.send(:"serialize_from_#{serialization_type}", keys)
13
13
  end
14
14
 
15
- def store(user, scope)
16
- @scope = scope
17
- return unless valid?
18
- super
19
- end
20
-
21
15
  def fetch(scope)
22
16
  @scope = scope
23
- return unless valid?
24
- super
25
- end
26
-
27
- def delete(scope, user=nil)
28
- @scope = scope
29
- return unless valid?
30
17
  super
31
18
  end
32
19
 
@@ -38,4 +25,4 @@ module Devise
38
25
  end
39
26
  end
40
27
  end
41
- end
28
+ end
@@ -10,17 +10,19 @@ module Devise
10
10
  super
11
11
  end
12
12
  end
13
-
13
+
14
14
  def default_options(record)
15
15
  super.merge!(:expires => record.remember_expires_at)
16
16
  end
17
17
 
18
18
  def delete(scope, record=nil)
19
- record.forget_me! if record && record.respond_to?(:forget_me!)
20
- super
19
+ if record && record.respond_to?(:forget_me!)
20
+ record.forget_me!
21
+ super
22
+ end
21
23
  end
22
24
  end
23
25
  end
24
26
  end
25
27
 
26
- Warden::Serializers.add(:rememberable, Devise::Serializers::Rememberable)
28
+ Warden::Serializers.add(:rememberable, Devise::Serializers::Rememberable)
@@ -5,40 +5,20 @@ module Devise
5
5
  class Authenticatable < Warden::Strategies::Base
6
6
  include Devise::Strategies::Base
7
7
 
8
+ def valid?
9
+ super && params[scope] && params[scope][:password].present?
10
+ end
11
+
8
12
  # Authenticate a user based on email and password params, returning to warden
9
13
  # success and the authenticated user if everything is okay. Otherwise redirect
10
14
  # to sign in page.
11
- #
12
- # Please notice the semantic difference between calling fail! and throw :warden.
13
- # The first does not perform any action when calling authenticate, just
14
- # when authenticate! is invoked. The second always perform the action.
15
15
  def authenticate!
16
- if valid_attributes?
17
- if resource = mapping.to.authenticate(params[scope])
18
- success!(resource)
19
- else
20
- fail!(:invalid)
21
- end
16
+ if resource = mapping.to.authenticate(params[scope])
17
+ success!(resource)
22
18
  else
23
- store_location
24
- fail!(:unauthenticated)
19
+ fail!(:invalid)
25
20
  end
26
21
  end
27
-
28
- private
29
-
30
- # Check if params and password are given. Others are checked inside authenticate.
31
- def valid_attributes?
32
- params[scope] && params[scope][:password].present?
33
- end
34
-
35
- # Stores requested uri to redirect the user after signing in. We cannot use
36
- # scoped session provided by warden here, since the user is not authenticated
37
- # yet, but we still need to store the uri based on scope, so different scopes
38
- # would never use the same uri to redirect.
39
- def store_location
40
- session[:"#{mapping.name}.return_to"] ||= request.request_uri if request.get?
41
- end
42
22
  end
43
23
  end
44
24
  end
@@ -1,3 +1,3 @@
1
1
  module Devise
2
- VERSION = "0.5.6".freeze
2
+ VERSION = "0.6.0".freeze
3
3
  end
@@ -21,8 +21,8 @@ class Encryptors < ActiveSupport::TestCase
21
21
  Devise::ENCRYPTORS_LENGTH.each do |key, value|
22
22
  test "should have length #{value} for #{key.inspect}" do
23
23
  swap Devise, :encryptor => key do
24
- assert_equal value, Devise.encryptor.digest('a', 2, 'b', 'c').size
24
+ assert_equal value, Devise::Encryptors.const_get(key.to_s.classify).digest('a', 2, 'b', 'c').size
25
25
  end
26
26
  end
27
27
  end
28
- end
28
+ end
@@ -12,8 +12,8 @@ class FailureTest < ActiveSupport::TestCase
12
12
  assert_equal 302, call_failure.first
13
13
  end
14
14
 
15
- test 'return redirect location based on mapping with params' do
16
- assert_equal '/users/sign_in', call_failure.second['Location']
15
+ test 'return to the default redirect location' do
16
+ assert_equal '/users/sign_in?unauthenticated=true', call_failure.second['Location']
17
17
  end
18
18
 
19
19
  test 'uses the proxy failure message' do
@@ -27,6 +27,6 @@ class FailureTest < ActiveSupport::TestCase
27
27
  end
28
28
 
29
29
  test 'setup a default message' do
30
- assert_equal ['You are being redirected to /users/sign_in'], call_failure.last
30
+ assert_equal ['You are being redirected to /users/sign_in?unauthenticated=true'], call_failure.last
31
31
  end
32
32
  end
@@ -3,7 +3,7 @@ require 'digest/sha1'
3
3
 
4
4
  class AuthenticatableTest < ActiveSupport::TestCase
5
5
 
6
- def encrypt_password(user, pepper=User.pepper, stretches=User.stretches, encryptor = ::Devise::Encryptors::Sha1)
6
+ def encrypt_password(user, pepper=User.pepper, stretches=User.stretches, encryptor=::Devise::Encryptors::Sha1)
7
7
  encryptor.digest('123456', stretches, user.password_salt, pepper)
8
8
  end
9
9
 
@@ -82,24 +82,23 @@ class AuthenticatableTest < ActiveSupport::TestCase
82
82
  end
83
83
 
84
84
  test 'should fallback to devise stretches default configuring' do
85
- begin
86
- default_stretches = Devise.stretches
87
- Devise.stretches = 1
85
+ swap Devise, :stretches => 1 do
88
86
  user = new_user
89
87
  assert_equal encrypt_password(user, nil, 1), user.encrypted_password
90
88
  assert_not_equal encrypt_password(user, nil, 2), user.encrypted_password
91
- ensure
92
- Devise.stretches = default_stretches
93
89
  end
94
90
  end
95
91
 
96
92
  test 'should respect encryptor configuration' do
97
- begin
98
- Devise.encryptor = ::Devise::Encryptors::Sha512
99
- user = create_user
100
- assert_equal user.encrypted_password, encrypt_password(user, User.pepper, User.stretches, ::Devise::Encryptors::Sha512)
101
- ensure
102
- Devise.encryptor = ::Devise::Encryptors::Sha1
93
+ User.instance_variable_set(:@encryptor_class, nil)
94
+
95
+ swap Devise, :encryptor => :sha512 do
96
+ begin
97
+ user = create_user
98
+ assert_equal user.encrypted_password, encrypt_password(user, User.pepper, User.stretches, ::Devise::Encryptors::Sha512)
99
+ ensure
100
+ User.instance_variable_set(:@encryptor_class, nil)
101
+ end
103
102
  end
104
103
  end
105
104
 
@@ -1,23 +1,23 @@
1
1
  require 'test/test_helper'
2
2
 
3
3
  class Authenticable < User
4
- devise
4
+ devise :authenticatable
5
5
  end
6
6
 
7
7
  class Confirmable < User
8
- devise :confirmable
8
+ devise :authenticatable, :confirmable
9
9
  end
10
10
 
11
11
  class Recoverable < User
12
- devise :recoverable
12
+ devise :authenticatable, :recoverable
13
13
  end
14
14
 
15
15
  class Rememberable < User
16
- devise :rememberable
16
+ devise :authenticatable, :rememberable
17
17
  end
18
18
 
19
19
  class Validatable < User
20
- devise :validatable
20
+ devise :authenticatable, :validatable
21
21
  end
22
22
 
23
23
  class Devisable < User
@@ -36,7 +36,6 @@ class Configurable < User
36
36
  end
37
37
 
38
38
  class ActiveRecordTest < ActiveSupport::TestCase
39
-
40
39
  def include_module?(klass, mod)
41
40
  klass.devise_modules.include?(mod) &&
42
41
  klass.included_modules.include?(Devise::Models::const_get(mod.to_s.classify))
@@ -90,19 +89,19 @@ class ActiveRecordTest < ActiveSupport::TestCase
90
89
  end
91
90
 
92
91
  test 'set a default value for stretches' do
93
- assert_equal 15, Configurable.new.stretches
92
+ assert_equal 15, Configurable.stretches
94
93
  end
95
94
 
96
95
  test 'set a default value for pepper' do
97
- assert_equal 'abcdef', Configurable.new.pepper
96
+ assert_equal 'abcdef', Configurable.pepper
98
97
  end
99
98
 
100
99
  test 'set a default value for confirm_within' do
101
- assert_equal 5.days, Configurable.new.confirm_within
100
+ assert_equal 5.days, Configurable.confirm_within
102
101
  end
103
102
 
104
103
  test 'set a default value for remember_for' do
105
- assert_equal 7.days, Configurable.new.remember_for
104
+ assert_equal 7.days, Configurable.remember_for
106
105
  end
107
106
 
108
107
  test 'set null fields on migrations' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jos\xC3\xA9 Valim"
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-11-21 00:00:00 -02:00
13
+ date: 2009-11-22 00:00:00 -02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -79,6 +79,7 @@ files:
79
79
  - lib/devise/models/rememberable.rb
80
80
  - lib/devise/models/validatable.rb
81
81
  - lib/devise/orm/active_record.rb
82
+ - lib/devise/orm/data_mapper.rb
82
83
  - lib/devise/orm/mongo_mapper.rb
83
84
  - lib/devise/rails.rb
84
85
  - lib/devise/rails/routes.rb