Permalink
Browse files

Fixed some Ruby 1.9 issues/bugs.

  • Loading branch information...
1 parent f50ec77 commit 0c7c762c160343032087c1734089cbd62ec9e72f @grimen grimen committed with josevalim Jan 21, 2010
Showing with 9 additions and 6 deletions.
  1. +2 −1 app/models/devise_mailer.rb
  2. +2 −2 lib/devise/encryptors/bcrypt.rb
  3. +3 −1 test/encryptors_test.rb
  4. +2 −2 test/models/validatable_test.rb
@@ -44,7 +44,8 @@ def render_with_scope(key, mapping, assigns)
def mailer_sender(mapping)
if Devise.mailer_sender.is_a?(Proc)
- Devise.mailer_sender.call(mapping.name)
+ block_args = mapping.name if Devise.mailer_sender.arity > 0
+ Devise.mailer_sender.call(*block_args)
else
Devise.mailer_sender
end
@@ -2,10 +2,10 @@
module Devise
module Encryptors
- # = BCrypt
+ # = BCrypt
# Uses the BCrypt hash algorithm to encrypt passwords.
class Bcrypt < Base
-
+
# Gererates a default password digest based on stretches, salt, pepper and the
# incoming password. We don't strech it ourselves since BCrypt does so internally.
def self.digest(password, stretches, salt, pepper)
View
@@ -1,3 +1,5 @@
+gem 'bcrypt-ruby'
+
class Encryptors < ActiveSupport::TestCase
test 'should match a password created by authlogic' do
@@ -17,7 +19,7 @@ class Encryptors < ActiveSupport::TestCase
encryptor = Devise::Encryptors::ClearanceSha1.digest('123mudar', nil, '65c58472c207c829f28c68619d3e3aefed18ab3f', nil)
assert_equal clearance, encryptor
end
-
+
Devise::ENCRYPTORS_LENGTH.each do |key, value|
test "should have length #{value} for #{key.inspect}" do
swap Devise, :encryptor => key do
@@ -18,7 +18,7 @@ class ValidatableTest < ActiveSupport::TestCase
user.email = existing_user.email
assert user.invalid?
assert user.errors[:email]
- assert_equal 1, user.errors[:email].to_a.size
+ assert_equal 1, [*user.errors[:email]].size
assert_equal 'has already been taken', user.errors[:email]
end
@@ -30,7 +30,7 @@ class ValidatableTest < ActiveSupport::TestCase
user.email = email
assert user.invalid?, 'should be invalid with email ' << email
assert user.errors[:email]
- assert_equal 1, user.errors[:email].to_a.size
+ assert_equal 1, [*user.errors[:email]].size
assert_equal 'is invalid', user.errors[:email]
end
end

0 comments on commit 0c7c762

Please sign in to comment.