Skip to content

Commit

Permalink
Added required_fields when reconfirmable
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Flores committed Feb 22, 2012
1 parent bc11e9f commit a909bfa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/devise/models/confirmable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ module Confirmable
end

def self.required_fields(klass)
[:confirmation_token, :confirmed_at, :confirmation_sent_at]
required_methods = [:confirmation_token, :confirmed_at, :confirmation_sent_at]
if klass.reconfirmable
required_methods << :unconfirmed_email
end

required_methods
end

# Confirm a user by setting it's confirmed_at to actual time. If the user
Expand Down
9 changes: 9 additions & 0 deletions test/models/confirmable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,13 @@ class ReconfirmableTest < ActiveSupport::TestCase
:confirmed_at
]
end

test 'required_fields should also contain unconfirmable when reconfirmable_email is true' do
assert_same_content Devise::Models::Confirmable.required_fields(Admin), [
:confirmation_sent_at,
:confirmation_token,
:confirmed_at,
:unconfirmable_email
]
end
end

0 comments on commit a909bfa

Please sign in to comment.