authlogic 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of authlogic might be problematic. Click here for more details.
- data/CHANGELOG.rdoc +6 -0
- data/Manifest.txt +1 -0
- data/README.rdoc +6 -5
- data/lib/authlogic/acts_as_authentic/email.rb +10 -1
- data/lib/authlogic/acts_as_authentic/login.rb +11 -2
- data/lib/authlogic/acts_as_authentic/session_maintenance.rb +3 -3
- data/lib/authlogic/session/activation.rb +2 -0
- data/lib/authlogic/session/active_record_trickery.rb +8 -0
- data/lib/authlogic/session/callbacks.rb +2 -3
- data/lib/authlogic/session/cookies.rb +6 -4
- data/lib/authlogic/session/existence.rb +3 -2
- data/lib/authlogic/session/validation.rb +2 -2
- data/lib/authlogic/test_case.rb +27 -14
- data/lib/authlogic/test_case/controller_adapter.rb +31 -0
- data/lib/authlogic/test_case/mock_controller.rb +2 -0
- data/lib/authlogic/test_case/mock_cookie_jar.rb +1 -1
- data/lib/authlogic/test_case/mock_request.rb +1 -1
- data/lib/authlogic/version.rb +1 -6
- data/test/acts_as_authentic_test/email_test.rb +10 -0
- data/test/acts_as_authentic_test/login_test.rb +10 -0
- metadata +3 -2
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 2.0.4 released 2009-3-28
|
2
|
+
|
3
|
+
* Added validates_uniqueness_of_login_field_options and validates_uniqueness_of_email_field_options configuration options
|
4
|
+
* Add in checks to make sure session_class is not nil.
|
5
|
+
* Cleaned up TestCase some more and added functionality to log users in during functional tests.
|
6
|
+
|
1
7
|
== 2.0.3 released 2009-3-26
|
2
8
|
|
3
9
|
* Fixed error where default session class does not exist.
|
data/Manifest.txt
CHANGED
@@ -55,6 +55,7 @@ lib/authlogic/session/timeout.rb
|
|
55
55
|
lib/authlogic/session/unauthorized_record.rb
|
56
56
|
lib/authlogic/session/validation.rb
|
57
57
|
lib/authlogic/test_case.rb
|
58
|
+
lib/authlogic/test_case/controller_adapter.rb
|
58
59
|
lib/authlogic/test_case/mock_controller.rb
|
59
60
|
lib/authlogic/test_case/mock_cookie_jar.rb
|
60
61
|
lib/authlogic/test_case/mock_request.rb
|
data/README.rdoc
CHANGED
@@ -63,7 +63,7 @@ These modules are for the acts_as_authentic method you call in your model. It co
|
|
63
63
|
These modules are for the "session side" of authentication. They create a new domain for session logic, allowing you to create, destroy, and ultimately manage your sessions.
|
64
64
|
|
65
65
|
* Authlogic::Session::BruteForceProtection - Disables accounts after a certain number of consecutive failed logins attempted.
|
66
|
-
* Authlogic::Session::Callbacks - Your tools to extend, change, or add onto Authlogic. Lets you hook in and do just about anything you want.
|
66
|
+
* Authlogic::Session::Callbacks - Your tools to extend, change, or add onto Authlogic. Lets you hook in and do just about anything you want. Start here if you want to write a plugin or add on for Authlogic
|
67
67
|
* Authlogic::Session::Cookies - Authentication via cookies.
|
68
68
|
* Authlogic::Session::Existence - Creating, saving, and destroying objects.
|
69
69
|
* Authlogic::Session::HttpAuth - Authentication via basic HTTP authentication.
|
@@ -85,7 +85,8 @@ Miscellaneous modules that don't really belong solely to either the session or m
|
|
85
85
|
* Authlogic::AuthenticatesMany - Responsible for allowing you to scope sessions to a parent record. Similar to a has_many and belongs_to relationship. This lets you do the same thing with sessions.
|
86
86
|
* Authlogic::CryptoProviders - Contains various encryption algorithms that Authlogic uses, allowing you to choose your encryption method.
|
87
87
|
* Authlogic::I18n - Acts JUST LIKE the rails I18n library, and provides internationalization to Authlogic.
|
88
|
-
* Authlogic::
|
88
|
+
* Authlogic::Random - A simple class to generate random tokens.
|
89
|
+
* Authlogic::TestCase - Various helper methods for testing frameworks to help you test your code.
|
89
90
|
* Authlogic::Version - A handy class for determine the version of Authlogic in a number of ways.
|
90
91
|
|
91
92
|
== Quick example
|
@@ -183,9 +184,9 @@ This will create a file that looks similar to:
|
|
183
184
|
The user model should have the following columns. The names of these columns can be changed with configuration. Better yet, Authlogic tries to guess these names by checking for the existence of common names. See the sub modules of Authlogic::Session for more details, but chances are you won't have to specify any configuration for your field names, even if they aren't the same names as below.
|
184
185
|
|
185
186
|
t.string :login, :null => false # optional, you can use email instead, or both
|
186
|
-
t.string :crypted_password, :null => false
|
187
|
+
t.string :crypted_password, :null => false # required
|
187
188
|
t.string :password_salt, :null => false # optional, but highly recommended
|
188
|
-
t.string :persistence_token, :null => false
|
189
|
+
t.string :persistence_token, :null => false # required
|
189
190
|
t.string :single_access_token, :null => false # optional, see Authlogic::Session::Params
|
190
191
|
t.string :perishable_token, :null => false # optional, see Authlogic::Session::Perishability
|
191
192
|
t.integer :login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns
|
@@ -220,7 +221,7 @@ Here are some common next steps. They might or might not apply to you. For a com
|
|
220
221
|
6. Need to reset passwords or activate accounts? Use the perishable token. See Authlogic::ActsAsAuthentic::PerishableToken
|
221
222
|
7. Need to give API access or access to a private feed? Use basic HTTP auth or authentication by params. See Authlogic::Session::HttpAuth or Authlogic::Session::Params
|
222
223
|
8. Need to internationalize your app? See Authlogic::I18n
|
223
|
-
9. Need help testing? See the Authlogic::
|
224
|
+
9. Need help testing? See the Authlogic::TestCase
|
224
225
|
|
225
226
|
== Interested in how it works?
|
226
227
|
|
@@ -50,6 +50,15 @@ module Authlogic
|
|
50
50
|
end
|
51
51
|
alias_method :validates_format_of_email_field_options=, :validates_format_of_email_field_options
|
52
52
|
|
53
|
+
# A hash of options for the validates_uniqueness_of call for the email field. Allows you to change this however you want.
|
54
|
+
#
|
55
|
+
# * <tt>Default:</tt> {:scope => validations_scope, :if => "#{email_field}_changed?".to_sym}
|
56
|
+
# * <tt>Accepts:</tt> Hash of options accepted by validates_uniqueness_of
|
57
|
+
def validates_uniqueness_of_email_field_options(value = nil)
|
58
|
+
config(:validates_uniqueness_of_email_field_options, value, {:scope => validations_scope, :if => "#{email_field}_changed?".to_sym})
|
59
|
+
end
|
60
|
+
alias_method :validates_uniqueness_of_email_field_options=, :validates_uniqueness_of_email_field_options
|
61
|
+
|
53
62
|
private
|
54
63
|
def email_regex
|
55
64
|
return @email_regex if @email_regex
|
@@ -67,7 +76,7 @@ module Authlogic
|
|
67
76
|
if validate_email_field && email_field
|
68
77
|
validates_length_of email_field, validates_length_of_email_field_options
|
69
78
|
validates_format_of email_field, validates_format_of_email_field_options
|
70
|
-
validates_uniqueness_of email_field,
|
79
|
+
validates_uniqueness_of email_field, validates_uniqueness_of_email_field_options
|
71
80
|
end
|
72
81
|
end
|
73
82
|
end
|
@@ -38,7 +38,7 @@ module Authlogic
|
|
38
38
|
end
|
39
39
|
alias_method :validates_length_of_login_field_options=, :validates_length_of_login_field_options
|
40
40
|
|
41
|
-
# A hash of options for the validates_format_of call for the
|
41
|
+
# A hash of options for the validates_format_of call for the login field. Allows you to change this however you want.
|
42
42
|
#
|
43
43
|
# * <tt>Default:</tt> {:with => /\A\w[\w\.\-_@ ]+\z/, :message => I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")}
|
44
44
|
# * <tt>Accepts:</tt> Hash of options accepted by validates_format_of
|
@@ -46,6 +46,15 @@ module Authlogic
|
|
46
46
|
config(:validates_format_of_login_field_options, value, {:with => /\A\w[\w\.\-_@ ]+\z/, :message => I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")})
|
47
47
|
end
|
48
48
|
alias_method :validates_format_of_login_field_options=, :validates_format_of_login_field_options
|
49
|
+
|
50
|
+
# A hash of options for the validates_uniqueness_of call for the login field. Allows you to change this however you want.
|
51
|
+
#
|
52
|
+
# * <tt>Default:</tt> {:scope => validations_scope, :if => "#{login_field}_changed?".to_sym}
|
53
|
+
# * <tt>Accepts:</tt> Hash of options accepted by validates_uniqueness_of
|
54
|
+
def validates_uniqueness_of_login_field_options(value = nil)
|
55
|
+
config(:validates_uniqueness_of_login_field_options, value, {:scope => validations_scope, :if => "#{login_field}_changed?".to_sym})
|
56
|
+
end
|
57
|
+
alias_method :validates_uniqueness_of_login_field_options=, :validates_uniqueness_of_login_field_options
|
49
58
|
end
|
50
59
|
|
51
60
|
# All methods relating to the login field
|
@@ -55,7 +64,7 @@ module Authlogic
|
|
55
64
|
if validate_login_field && login_field
|
56
65
|
validates_length_of login_field, validates_length_of_login_field_options
|
57
66
|
validates_format_of login_field, validates_format_of_login_field_options
|
58
|
-
validates_uniqueness_of login_field,
|
67
|
+
validates_uniqueness_of login_field, validates_uniqueness_of_login_field_options
|
59
68
|
end
|
60
69
|
end
|
61
70
|
end
|
@@ -5,7 +5,7 @@ module Authlogic
|
|
5
5
|
#
|
6
6
|
# Just to clear up any confusion, Authlogic stores both the record id and the persistence token in the session.
|
7
7
|
# Why? So stale sessions can not be persisted. It stores the id so it can quickly find the record, and the
|
8
|
-
# persistence token to ensure no sessions are stale. So if the persistence token changes, the user
|
8
|
+
# persistence token to ensure no sessions are stale. So if the persistence token changes, the user must log
|
9
9
|
# back in.
|
10
10
|
#
|
11
11
|
# Well, the persistence token changes with the password. What happens if the user changes his own password?
|
@@ -42,7 +42,7 @@ module Authlogic
|
|
42
42
|
# * <tt>Default:</tt> "#{klass.name}Session".constantize
|
43
43
|
# * <tt>Accepts:</tt> Class
|
44
44
|
def session_class(value = nil)
|
45
|
-
const = "#{name}Session".constantize rescue nil
|
45
|
+
const = "#{base_class.name}Session".constantize rescue nil
|
46
46
|
config(:session_class, value, const)
|
47
47
|
end
|
48
48
|
alias_method :session_class=, :session_class
|
@@ -74,7 +74,7 @@ module Authlogic
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def update_sessions?
|
77
|
-
!skip_session_maintenance && session_class.activated? && !session_ids.blank? && persistence_token_changed?
|
77
|
+
!skip_session_maintenance && session_class && session_class.activated? && !session_ids.blank? && persistence_token_changed?
|
78
78
|
end
|
79
79
|
|
80
80
|
def get_session_information
|
@@ -29,6 +29,8 @@ module Authlogic
|
|
29
29
|
# This accepts a controller object wrapped with the Authlogic controller adapter. The controller adapters close the gap
|
30
30
|
# between the different controllers in each framework. That being said, Authlogic is expecting your object's class to
|
31
31
|
# extend Authlogic::ControllerAdapters::AbstractAdapter. See Authlogic::ControllerAdapters for more info.
|
32
|
+
#
|
33
|
+
# Lastly, this is thread safe.
|
32
34
|
def controller=(value)
|
33
35
|
Thread.current[:authlogic_controller] = value
|
34
36
|
end
|
@@ -11,12 +11,19 @@ module Authlogic
|
|
11
11
|
end
|
12
12
|
|
13
13
|
module ClassMethods
|
14
|
+
# How to name the attributes of Authlogic, works JUST LIKE ActiveRecord, but instead it uses the following
|
15
|
+
# namespace:
|
16
|
+
#
|
17
|
+
# authlogic.attributes.user_session.login
|
14
18
|
def human_attribute_name(attribute_key_name, options = {})
|
15
19
|
options[:count] ||= 1
|
16
20
|
options[:default] ||= attribute_key_name.humanize
|
17
21
|
I18n.t("attributes.#{name.underscore}.#{attribute_key_name}", options)
|
18
22
|
end
|
19
23
|
|
24
|
+
# How to name the class, works JUST LIKE ActiveRecord, except it uses the following namespace:
|
25
|
+
#
|
26
|
+
# authlogic.models.user_session
|
20
27
|
def human_name(*args)
|
21
28
|
I18n.t("models.#{name.underscore}", {:count => 1, :default => name.humanize})
|
22
29
|
end
|
@@ -33,6 +40,7 @@ module Authlogic
|
|
33
40
|
end
|
34
41
|
|
35
42
|
module InstanceMethods
|
43
|
+
# Don't use this yourself, this is to just trick some of the helpers since this is the method it calls.
|
36
44
|
def new_record?
|
37
45
|
new_session?
|
38
46
|
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
module Authlogic
|
2
2
|
module Session
|
3
3
|
# Between these callsbacks and the configuration, this is the contract between me and you to safely
|
4
|
-
# modify Authlogic's behavior.
|
5
|
-
# For example, going from v1.X.X to 2.0.0.
|
4
|
+
# modify Authlogic's behavior. I will do everything I can to make sure these do not change.
|
6
5
|
#
|
7
6
|
# Check out the sub modules of Authlogic::Session. They are very concise, clear, and to the point. More
|
8
7
|
# importantly they use the same API that you would use to extend Authlogic. That being said, they are great
|
9
|
-
# examples of how to extend Authlogic and add / modify behavior. These modules could easily be pulled out
|
8
|
+
# examples of how to extend Authlogic and add / modify behavior to Authlogic. These modules could easily be pulled out
|
10
9
|
# into their own plugin and become an "add on" without any change.
|
11
10
|
#
|
12
11
|
# Now to the point of this module. Just like in ActiveRecord you have before_save, before_validation, etc.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Authlogic
|
2
2
|
module Session
|
3
|
-
# Handles all authentication that deals with cookies, such as persisting
|
3
|
+
# Handles all authentication that deals with cookies, such as persisting, saving, and destroying.
|
4
4
|
module Cookies
|
5
5
|
def self.included(klass)
|
6
6
|
klass.class_eval do
|
@@ -50,7 +50,8 @@ module Authlogic
|
|
50
50
|
end
|
51
51
|
|
52
52
|
# The methods available for an Authlogic::Session::Base object that make up the cookie feature set.
|
53
|
-
module InstanceMethods
|
53
|
+
module InstanceMethods
|
54
|
+
# Allows you to set the remember_me option when passing credentials.
|
54
55
|
def credentials=(value)
|
55
56
|
super
|
56
57
|
values = value.is_a?(Array) ? value : [value]
|
@@ -63,7 +64,8 @@ module Authlogic
|
|
63
64
|
end
|
64
65
|
end
|
65
66
|
|
66
|
-
|
67
|
+
# Is the cookie going to expire after the session is over, or will it stick around?
|
68
|
+
def remember_me
|
67
69
|
return @remember_me if defined?(@remember_me)
|
68
70
|
@remember_me = self.class.remember_me
|
69
71
|
end
|
@@ -73,7 +75,7 @@ module Authlogic
|
|
73
75
|
@remember_me = value
|
74
76
|
end
|
75
77
|
|
76
|
-
#
|
78
|
+
# See remember_me
|
77
79
|
def remember_me?
|
78
80
|
remember_me == true || remember_me == "true" || remember_me == "1"
|
79
81
|
end
|
@@ -20,7 +20,7 @@ module Authlogic
|
|
20
20
|
# A convenince method. The same as:
|
21
21
|
#
|
22
22
|
# session = UserSession.new(*args)
|
23
|
-
# session.
|
23
|
+
# session.save
|
24
24
|
#
|
25
25
|
# Instead you can do:
|
26
26
|
#
|
@@ -49,7 +49,8 @@ module Authlogic
|
|
49
49
|
true
|
50
50
|
end
|
51
51
|
|
52
|
-
# Returns true if the session has
|
52
|
+
# Returns true if the session is new, meaning no action has been taken on it and a successful save
|
53
|
+
# has not taken place.
|
53
54
|
def new_session?
|
54
55
|
new_session != false
|
55
56
|
end
|
@@ -10,7 +10,7 @@ module Authlogic
|
|
10
10
|
# private
|
11
11
|
# def check_if_awesome
|
12
12
|
# errors.add(:login, "must contain awesome") if login && !login.include?("awesome")
|
13
|
-
# errors.add_to_base("You must be awesome to log in") unless
|
13
|
+
# errors.add_to_base("You must be awesome to log in") unless attempted_record.awesome?
|
14
14
|
# end
|
15
15
|
# end
|
16
16
|
class Errors < ::ActiveRecord::Errors
|
@@ -39,7 +39,7 @@ module Authlogic
|
|
39
39
|
# private
|
40
40
|
# def check_if_awesome
|
41
41
|
# errors.add(:login, "must contain awesome") if login && !login.include?("awesome")
|
42
|
-
# errors.add_to_base("You must be awesome to log in") unless
|
42
|
+
# errors.add_to_base("You must be awesome to log in") unless attempted_record.awesome?
|
43
43
|
# end
|
44
44
|
# end
|
45
45
|
def errors
|
data/lib/authlogic/test_case.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "authlogic/test_case/controller_adapter"
|
1
2
|
require "authlogic/test_case/mock_cookie_jar"
|
2
3
|
require "authlogic/test_case/mock_request"
|
3
4
|
require "authlogic/test_case/mock_controller"
|
@@ -8,16 +9,23 @@ module Authlogic
|
|
8
9
|
#
|
9
10
|
# Some important things to keep in mind when testing:
|
10
11
|
#
|
11
|
-
# Authlogic requires a "connection" to your controller. In the same manner that ActiveRecord requires a connection to
|
12
|
+
# Authlogic requires a "connection" to your controller to activate it. In the same manner that ActiveRecord requires a connection to
|
12
13
|
# your database. It can't do anything until it gets connnected. That being said, Authlogic will raise an
|
13
14
|
# Authlogic::Session::Activation::NotActivatedError any time you try to instantiate an object without a "connection".
|
14
|
-
# So before you do anything with Authlogic, you need to connect
|
15
|
+
# So before you do anything with Authlogic, you need to activate / connect Authlogic. Let's walk through how to do this in tests:
|
15
16
|
#
|
16
17
|
# === Functional tests
|
17
18
|
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
19
|
+
# Activating Authlogic isn't a problem here, because making a request will activate Authlogic for you. The problem is
|
20
|
+
# logging users in so they can access restricted areas. Solvin this is simple, just do this:
|
21
|
+
#
|
22
|
+
# setup :activate_authlogic
|
23
|
+
#
|
24
|
+
# Now log users in using Authlogic:
|
25
|
+
#
|
26
|
+
# UserSession.create(users(:whomever))
|
27
|
+
#
|
28
|
+
# Do this before you make your request and it will act as if that user is logged in.
|
21
29
|
#
|
22
30
|
# === Integration tests
|
23
31
|
#
|
@@ -26,22 +34,24 @@ module Authlogic
|
|
26
34
|
#
|
27
35
|
# === Unit tests
|
28
36
|
#
|
29
|
-
#
|
30
|
-
#
|
37
|
+
# The only time you need to do any trickiness here is if you want to test Authlogic yourself. Maybe you added some custom
|
38
|
+
# code or methods in your Session class. Maybe you are writing a plugin or a library that extends Authlogic. Whatever it is
|
39
|
+
# you need to make sure your code is tested and working properly.
|
40
|
+
#
|
41
|
+
# That being said, in this environment there is no controller. So you need to "fake" Authlogic into
|
42
|
+
# thinking there is. Don't worry, because the this module takes care of this for you. Just do the following
|
31
43
|
# in your test's setup and you are good to go:
|
32
44
|
#
|
33
45
|
# setup :activate_authlogic
|
34
46
|
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
# You can even test off of this controller to make sure everything is good. For example:
|
47
|
+
# You also get a controller method that you can test off of. For example:
|
38
48
|
#
|
39
49
|
# ben = users(:ben)
|
40
50
|
# assert_nil controller.session["user_credentials"]
|
41
51
|
# assert UserSession.create(ben)
|
42
52
|
# assert_equal controller.session["user_credentials"], ben.persistence_token
|
43
53
|
#
|
44
|
-
#
|
54
|
+
# That's it.
|
45
55
|
#
|
46
56
|
# === How to use
|
47
57
|
#
|
@@ -49,12 +59,15 @@ module Authlogic
|
|
49
59
|
#
|
50
60
|
# require "authlogic/test_case"
|
51
61
|
module TestCase
|
52
|
-
# Activates authlogic
|
62
|
+
# Activates authlogic so that you can use it in your tests. You should call this method in your test's setup. Ex:
|
63
|
+
#
|
64
|
+
# setup :activate_authlogic
|
53
65
|
def activate_authlogic
|
54
|
-
Authlogic::Session::Base.controller = controller
|
66
|
+
Authlogic::Session::Base.controller = (@request && Authlogic::TestCase::ControllerAdapter.new(@request)) || controller
|
55
67
|
end
|
56
68
|
|
57
|
-
# The Authlogic::TestCase::MockController object passed to Authlogic to activate it.
|
69
|
+
# The Authlogic::TestCase::MockController object passed to Authlogic to activate it. You can access this in your test.
|
70
|
+
# See the module description for an example.
|
58
71
|
def controller
|
59
72
|
@controller ||= Authlogic::TestCase::MockController.new
|
60
73
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Authlogic
|
2
|
+
module TestCase
|
3
|
+
# Adapts authlogic to work with the @request object when testing. This way Authlogic can set cookies and what not before
|
4
|
+
# a request is made, ultimately letting you log in users in functional tests.
|
5
|
+
class ControllerAdapter < ControllerAdapters::AbstractAdapter
|
6
|
+
def authenticate_with_http_basic(&block)
|
7
|
+
controller.authenticate_with_http_basic(&block)
|
8
|
+
end
|
9
|
+
|
10
|
+
def cookies
|
11
|
+
new_cookies = {}
|
12
|
+
super.each do |key, value|
|
13
|
+
new_cookies[key] = value[:value]
|
14
|
+
end
|
15
|
+
new_cookies
|
16
|
+
end
|
17
|
+
|
18
|
+
def cookie_domain
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def request
|
23
|
+
@request ||= MockRequest.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def request_content_type
|
27
|
+
request.format.to_s
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Authlogic
|
2
2
|
module TestCase
|
3
|
+
# Basically acts like a controller but doesn't do anything. Authlogic can interact with this, do it's thing and then you
|
4
|
+
# can look at the controller object to see if anything changed.
|
3
5
|
class MockController < ControllerAdapters::AbstractAdapter
|
4
6
|
attr_accessor :http_user, :http_password
|
5
7
|
attr_writer :request_content_type
|
data/lib/authlogic/version.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
module Authlogic # :nodoc:
|
2
|
-
# = Version
|
3
|
-
#
|
4
2
|
# A class for describing the current version of a library. The version
|
5
3
|
# consists of three parts: the +major+ number, the +minor+ number, and the
|
6
4
|
# +tiny+ (or +patch+) number.
|
7
5
|
class Version
|
8
|
-
|
9
6
|
include Comparable
|
10
7
|
|
11
8
|
# A convenience method for instantiating a new Version instance with the
|
@@ -44,13 +41,11 @@ module Authlogic # :nodoc:
|
|
44
41
|
|
45
42
|
MAJOR = 2
|
46
43
|
MINOR = 0
|
47
|
-
TINY =
|
44
|
+
TINY = 4
|
48
45
|
|
49
46
|
# The current version as a Version instance
|
50
47
|
CURRENT = new(MAJOR, MINOR, TINY)
|
51
48
|
# The current version as a String
|
52
49
|
STRING = CURRENT.to_s
|
53
|
-
|
54
50
|
end
|
55
|
-
|
56
51
|
end
|
@@ -43,6 +43,16 @@ module ActsAsAuthenticTest
|
|
43
43
|
assert_equal default, User.validates_format_of_email_field_options
|
44
44
|
end
|
45
45
|
|
46
|
+
def test_validates_uniqueness_of_email_field_options_config
|
47
|
+
default = {:scope => Employee.validations_scope, :if => "#{Employee.email_field}_changed?".to_sym}
|
48
|
+
assert_equal default, Employee.validates_uniqueness_of_email_field_options
|
49
|
+
|
50
|
+
Employee.validates_uniqueness_of_email_field_options = {:yes => "no"}
|
51
|
+
assert_equal({:yes => "no"}, Employee.validates_uniqueness_of_email_field_options)
|
52
|
+
Employee.validates_uniqueness_of_email_field_options default
|
53
|
+
assert_equal default, Employee.validates_uniqueness_of_email_field_options
|
54
|
+
end
|
55
|
+
|
46
56
|
def test_validates_length_of_email_field
|
47
57
|
u = User.new
|
48
58
|
u.email = "a@a.a"
|
@@ -43,6 +43,16 @@ module ActsAsAuthenticTest
|
|
43
43
|
assert_equal default, User.validates_format_of_login_field_options
|
44
44
|
end
|
45
45
|
|
46
|
+
def test_validates_uniqueness_of_login_field_options_config
|
47
|
+
default = {:scope => User.validations_scope, :if => "#{User.login_field}_changed?".to_sym}
|
48
|
+
assert_equal default, User.validates_uniqueness_of_login_field_options
|
49
|
+
|
50
|
+
User.validates_uniqueness_of_login_field_options = {:yes => "no"}
|
51
|
+
assert_equal({:yes => "no"}, User.validates_uniqueness_of_login_field_options)
|
52
|
+
User.validates_uniqueness_of_login_field_options default
|
53
|
+
assert_equal default, User.validates_uniqueness_of_login_field_options
|
54
|
+
end
|
55
|
+
|
46
56
|
def test_validates_length_of_login_field
|
47
57
|
u = User.new
|
48
58
|
u.login = "a"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authlogic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Johnson of Binary Logic
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-28 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- lib/authlogic/session/unauthorized_record.rb
|
101
101
|
- lib/authlogic/session/validation.rb
|
102
102
|
- lib/authlogic/test_case.rb
|
103
|
+
- lib/authlogic/test_case/controller_adapter.rb
|
103
104
|
- lib/authlogic/test_case/mock_controller.rb
|
104
105
|
- lib/authlogic/test_case/mock_cookie_jar.rb
|
105
106
|
- lib/authlogic/test_case/mock_request.rb
|