mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
All tests green on latest Rails beta.
This commit is contained in:
parent
7403c9f80e
commit
8db559148c
13 changed files with 32 additions and 13 deletions
17
app/helpers/devise_helper.rb
Normal file
17
app/helpers/devise_helper.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
module DeviseHelper
|
||||
def devise_error_messages!
|
||||
return "" if resource.errors.empty?
|
||||
|
||||
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
|
||||
sentence = "#{pluralize(resource.errors.count, "error")} prohibited this #{resource_name} from being saved:"
|
||||
|
||||
html = <<-HTML
|
||||
<div id="error_explanation">
|
||||
<h2>#{sentence}</h2>
|
||||
<ul>#{messages}</ul>
|
||||
</div>
|
||||
HTML
|
||||
|
||||
html.html_safe
|
||||
end
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
<h2>Resend confirmation instructions</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name)) do |f| %>
|
||||
<%= f.error_messages %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<p><%= f.label :email %></p>
|
||||
<p><%= f.text_field :email %></p>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<h2>Change your password</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
|
||||
<%= f.error_messages %>
|
||||
<%= devise_error_messages! %>
|
||||
<%= f.hidden_field :reset_password_token %>
|
||||
|
||||
<p><%= f.label :password %></p>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<h2>Forgot your password?</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name)) do |f| %>
|
||||
<%= f.error_messages %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<p><%= f.label :email %></p>
|
||||
<p><%= f.text_field :email %></p>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<h2>Edit <%= resource_name.to_s.humanize %></h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
|
||||
<%= f.error_messages %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<p><%= f.label :email %></p>
|
||||
<p><%= f.text_field :email %></p>
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<h2>Sign up</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
|
||||
<%= f.error_messages %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<p><%= f.label :email %></p>
|
||||
<p><%= f.text_field :email %></p>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<h2>Resend unlock instructions</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name)) do |f| %>
|
||||
<%= f.error_messages %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<p><%= f.label :email %></p>
|
||||
<p><%= f.text_field :email %></p>
|
||||
|
|
|
@ -9,6 +9,7 @@ module Devise
|
|||
|
||||
included do
|
||||
unloadable
|
||||
helper DeviseHelper
|
||||
|
||||
helpers = %w(resource scope_name resource_name
|
||||
resource_class devise_mapping devise_controller?)
|
||||
|
|
|
@ -26,7 +26,7 @@ class ConfirmationTest < ActionController::IntegrationTest
|
|||
|
||||
assert_response :success
|
||||
assert_template 'confirmations/new'
|
||||
assert_have_selector '#errorExplanation'
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_contain /Confirmation token(.*)invalid/
|
||||
end
|
||||
|
||||
|
@ -49,7 +49,7 @@ class ConfirmationTest < ActionController::IntegrationTest
|
|||
visit_user_confirmation_with_token(user.confirmation_token)
|
||||
|
||||
assert_template 'confirmations/new'
|
||||
assert_have_selector '#errorExplanation'
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_contain 'already confirmed'
|
||||
end
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ class LockTest < ActionController::IntegrationTest
|
|||
|
||||
assert_response :success
|
||||
assert_template 'unlocks/new'
|
||||
assert_have_selector '#errorExplanation'
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_contain /Unlock token(.*)invalid/
|
||||
end
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ class PasswordTest < ActionController::IntegrationTest
|
|||
|
||||
assert_response :success
|
||||
assert_template 'passwords/edit'
|
||||
assert_have_selector '#errorExplanation'
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_contain /Reset password token(.*)invalid/
|
||||
assert_not user.reload.valid_password?('987654321')
|
||||
end
|
||||
|
@ -91,7 +91,7 @@ class PasswordTest < ActionController::IntegrationTest
|
|||
|
||||
assert_response :success
|
||||
assert_template 'passwords/edit'
|
||||
assert_have_selector '#errorExplanation'
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_contain 'Password doesn\'t match confirmation'
|
||||
assert_not user.reload.valid_password?('987654321')
|
||||
end
|
||||
|
@ -113,7 +113,7 @@ class PasswordTest < ActionController::IntegrationTest
|
|||
fill_in 'Password confirmation', :with => 'other_password'
|
||||
end
|
||||
assert_response :success
|
||||
assert_have_selector '#errorExplanation'
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_not user.reload.valid_password?('987654321')
|
||||
|
||||
reset_password :reset_password_token => user.reload.reset_password_token, :visit => false
|
||||
|
|
|
@ -48,7 +48,7 @@ class RegistrationTest < ActionController::IntegrationTest
|
|||
click_button 'Sign up'
|
||||
|
||||
assert_template 'registrations/new'
|
||||
assert_have_selector '#errorExplanation'
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_contain "Email is invalid"
|
||||
assert_contain "Password doesn't match confirmation"
|
||||
assert_nil User.first
|
||||
|
|
Loading…
Add table
Reference in a new issue