From 533511f8c3a1fde4c6bd8bbd36fcfc4b6021298d Mon Sep 17 00:00:00 2001 From: Rodrigo Flores Date: Fri, 17 Feb 2012 15:31:00 -0200 Subject: [PATCH] Required fields on encryptable --- lib/devise/models/encryptable.rb | 10 +++++++++- test/models/encryptable_test.rb | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/devise/models/encryptable.rb b/lib/devise/models/encryptable.rb index 3913d168..8711fcc5 100644 --- a/lib/devise/models/encryptable.rb +++ b/lib/devise/models/encryptable.rb @@ -24,6 +24,14 @@ module Devise 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? @@ -69,4 +77,4 @@ module Devise end end end -end +end \ No newline at end of file diff --git a/test/models/encryptable_test.rb b/test/models/encryptable_test.rb index 066cafbd..2efff1b5 100644 --- a/test/models/encryptable_test.rb +++ b/test/models/encryptable_test.rb @@ -64,4 +64,10 @@ class EncryptableTest < ActiveSupport::TestCase 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