Skip to content

Commit

Permalink
Do not show unlock link unless strategy is e-mail. Closes heartcombo#204
Browse files Browse the repository at this point in the history
.
  • Loading branch information
josevalim committed Apr 15, 2010
1 parent b2a50db commit 731f156
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/views/devise/shared/_links.erb
Expand Up @@ -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 -%>
10 changes: 9 additions & 1 deletion test/integration/lockable_test.rb
Expand Up @@ -37,8 +37,16 @@ def visit_user_unlock_with_token(unlock_token)
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
Expand Down
2 changes: 1 addition & 1 deletion test/rails_app/config/initializers/secret_token.rb
@@ -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"

0 comments on commit 731f156

Please sign in to comment.