Do not show unlock link unless strategy is e-mail. Closes #204.

This commit is contained in:
José Valim 2010-04-15 08:40:15 +02:00
parent b2a50db1df
commit 731f156f50
3 changed files with 11 additions and 3 deletions

View File

@ -14,6 +14,6 @@
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.lockable? && controller_name != 'unlocks' %>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<% end -%>

View File

@ -37,8 +37,16 @@ class LockTest < ActionController::IntegrationTest
end
test 'unlocked pages should not be available if email strategy is disabled' do
visit new_user_unlock_path
visit "/users/sign_in"
click_link "Didn't receive unlock instructions?"
swap Devise, :unlock_strategy => :time do
visit "/users/sign_in"
assert_raise Webrat::NotFoundError do
click_link "Didn't receive unlock instructions?"
end
assert_raise AbstractController::ActionNotFound do
visit new_user_unlock_path
end

View File

@ -1,2 +1,2 @@
Rails.application.config.cookie_secret = 'ea942c41850d502f2c8283e26bdc57829f471bb18224ddff0a192c4f32cdf6cb5aa0d82b3a7a7adbeb640c4b06f3aa1cd5f098162d8240f669b39d6b49680571'
Rails.application.config.secret_token = 'ea942c41850d502f2c8283e26bdc57829f471bb18224ddff0a192c4f32cdf6cb5aa0d82b3a7a7adbeb640c4b06f3aa1cd5f098162d8240f669b39d6b49680571'
Rails.application.config.session_store :cookie_store, :key => "_my_app"