Permalink
Browse files

Fixes #318 and fixes #322 broken migrations caused by #290.

Signed-off-by: James McCarthy <james2mccarthy@gmail.com>
  • Loading branch information...
1 parent 8856d88 commit d1fdc90351697fc892b16baaf0ea381a9ca17e62 @james2m committed Jul 11, 2012
Showing with 11 additions and 1 deletion.
  1. +4 −1 lib/authlogic/acts_as_authentic/base.rb
  2. +7 −0 test/acts_as_authentic_test/base_test.rb
@@ -28,7 +28,10 @@ module Config
# See the various sub modules for the configuration they provide.
def acts_as_authentic(unsupported_options = nil, &block)
# Stop all configuration if the DB is not set up
- raise StandardError.new("You must establish a database connection before using acts_as_authentic") if !db_setup?
+ return unless table_exists?
+
+ # Raise an error if you've loaded the model without establishing a valid database connection.
+ raise StandardError.new("You must establish a database connection before using acts_as_authentic") unless connection.present?
raise ArgumentError.new("You are using the old v1.X.X configuration method for Authlogic. Instead of " +
"passing a hash of configuration options to acts_as_authentic, pass a block: acts_as_authentic { |c| c.my_option = my_value }") if !unsupported_options.nil?
@@ -14,5 +14,12 @@ def test_acts_as_authentic_with_old_config
User.acts_as_authentic({})
end
end
+
+ def test_acts_as_authentic_with_no_table
+ klass = Class.new(ActiveRecord::Base)
+ assert_nothing_raised do
+ klass.acts_as_authentic
+ end
+ end
end
end

0 comments on commit d1fdc90

Please sign in to comment.