Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added option to modify options for validates_presence_of for the pass…

…word confirmation field
  • Loading branch information...
commit 6306af36ca2ea3ae1ce9e21ea3b6731e77f8cc26 1 parent af9712b
Ben Johnson binarylogic authored
3  Manifest
View
@@ -1,4 +1,6 @@
CHANGELOG.rdoc
+generators/session/session_generator.rb
+generators/session/templates/session.rb
init.rb
lib/authlogic/controller_adapters/abstract_adapter.rb
lib/authlogic/controller_adapters/merb_adapter.rb
@@ -27,6 +29,7 @@ lib/authlogic/session/params.rb
lib/authlogic/session/perishability.rb
lib/authlogic/session/scopes.rb
lib/authlogic/session/session.rb
+lib/authlogic/testing/test_unit_helpers.rb
lib/authlogic/version.rb
lib/authlogic.rb
Manifest
6 README.rdoc
View
@@ -100,6 +100,10 @@ Lets assume you are setting up a session for your User model.
Create your user_session.rb file:
+ $ script/generate session user_session
+
+This will create a file that looks similar to:
+
# app/models/user_session.rb
class UserSession < Authlogic::Session::Base
# configuration here, just like ActiveRecord, or in an initializer
@@ -452,7 +456,7 @@ You get the following methods:
set_cookie_for(record_object)
set_http_auth_for(username, password)
-In your test, before you execute a request, just call one of those methods and it will set the proper values so that it will seems as if that record is logged in.
+In your test, before you execute a request, just call one of those methods and it will set the proper values so that it will seem as if that record is logged in.
You can also checkout the authlogic_example application (see helpful links above), the tests there use this.
7 lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/config.rb
View
@@ -127,9 +127,12 @@ module ActsAsAuthentic
# * <tt>password_field_validates_length_of_options</tt> - default: {:minimum => 4},
# These options are applied to the validates_length_of call for the :password_field
#
- # * <tt>login_field_validates_confirmation_of_options</tt> - default: {},
+ # * <tt>password_field_validates_confirmation_of_options</tt> - default: {},
# These options are applied to the validates_confirmation_of call for the :password_field
#
+ # * <tt>password_confirmation_field_validates_presence_of_options</tt> - default: {},
+ # These options are applied to the validates_presence_of call for the :password_confirmation_field.
+ #
# * <tt>email_field_validation_options</tt> - default: {},
# The same as :validation_options but these are only applied to validations that pertain to the :email_field
#
@@ -198,6 +201,8 @@ def acts_as_authentic_with_config(options = {})
end
end
+ options[:password_confirmation_field_validates_presence_of_options] ||= {}
+
if options[:scope]
options[:login_field_validates_uniqueness_of_options][:scope] ||= options[:scope]
options[:email_field_validates_uniqueness_of_options][:scope] ||= options[:scope]
2  lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/credentials.rb
View
@@ -42,7 +42,7 @@ def acts_as_authentic_with_credentials(options = {})
if options[:validate_password_field]
validates_length_of options[:password_field], {:minimum => 4}.merge(options[:password_field_validates_length_of_options].merge(:if => "validate_#{options[:password_field]}?".to_sym))
validates_confirmation_of options[:password_field], options[:password_field_validates_confirmation_of_options].merge(:if => "#{options[:password_salt_field]}_changed?".to_sym)
- validates_presence_of "#{options[:password_field]}_confirmation", :if => "#{options[:password_salt_field]}_changed?".to_sym
+ validates_presence_of "#{options[:password_field]}_confirmation", options[:password_confirmation_field_validates_presence_of_options].merge(:if => "#{options[:password_salt_field]}_changed?".to_sym)
end
if options[:validate_email_field] && options[:email_field]
2  lib/authlogic/session/base.rb
View
@@ -357,7 +357,7 @@ def create_configurable_methods!
return if respond_to?(login_field) # already created these methods
self.class.class_eval <<-"end_eval", __FILE__, __LINE__
- alias_method :#{klass_name.underscore.split("/").last}, :record
+ alias_method :#{klass_name.demodulize.underscore}, :record
attr_reader :#{login_field}
2  lib/authlogic/version.rb
View
@@ -44,7 +44,7 @@ def to_a
MAJOR = 1
MINOR = 3
- TINY = 6
+ TINY = 7
# The current version as a Version instance
CURRENT = new(MAJOR, MINOR, TINY)
3  test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/config_test.rb
View
@@ -45,7 +45,8 @@ def test_acts_as_authentic_config
:validate_email_field => true,
:validation_options => {},
:login_field_validation_options => {},
- :transition_from_crypto_provider => []
+ :transition_from_crypto_provider => [],
+ :password_confirmation_field_validates_presence_of_options => {}
}
assert_equal default_config, User.acts_as_authentic_config
end
Please sign in to comment.
Something went wrong with that request. Please try again.