Skip to content

Commit

Permalink
Required fields on encryptable
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Flores committed Feb 22, 2012
1 parent 6489354 commit 533511f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/devise/models/encryptable.rb
Expand Up @@ -24,6 +24,14 @@ module Encryptable
attr_accessor :password_confirmation
end

module ModuleMethods
extend self

def required_fields
[:password_salt]
end
end

# Generates password salt.
def password=(new_password)
self.password_salt = self.class.password_salt if new_password.present?
Expand Down Expand Up @@ -69,4 +77,4 @@ def password_salt
end
end
end
end
end
6 changes: 6 additions & 0 deletions test/models/encryptable_test.rb
Expand Up @@ -64,4 +64,10 @@ def swap_with_encryptor(klass, encryptor, options={})
admin.save
assert_not admin.valid_password?('123456')
end

test 'required_fields should contain the fields that Devise uses' do
assert_equal Devise::Models::Encryptable::ModuleMethods.required_fields, [
:password_salt
]
end
end

0 comments on commit 533511f

Please sign in to comment.