Skip to content

Commit

Permalink
All tests green on latest Rails beta.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Apr 13, 2010
1 parent 7403c9f commit 8db5591
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 13 deletions.
17 changes: 17 additions & 0 deletions app/helpers/devise_helper.rb
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
2 changes: 1 addition & 1 deletion app/views/devise/confirmations/new.html.erb
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/passwords/edit.html.erb
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/passwords/new.html.erb
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/registrations/edit.html.erb
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
3 changes: 2 additions & 1 deletion app/views/devise/registrations/new.html.erb
Original file line number Diff line number Diff line change
@@ -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>

Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/unlocks/new.html.erb
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
1 change: 1 addition & 0 deletions lib/devise/controllers/internal_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module InternalHelpers #:nodoc:

included do
unloadable
helper DeviseHelper

helpers = %w(resource scope_name resource_name
resource_class devise_mapping devise_controller?)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/confirmable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def visit_user_confirmation_with_token(confirmation_token)

assert_response :success
assert_template 'confirmations/new'
assert_have_selector '#errorExplanation'
assert_have_selector '#error_explanation'
assert_contain /Confirmation token(.*)invalid/
end

Expand All @@ -49,7 +49,7 @@ def visit_user_confirmation_with_token(confirmation_token)
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

Expand Down
2 changes: 1 addition & 1 deletion test/integration/lockable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def visit_user_unlock_with_token(unlock_token)

assert_response :success
assert_template 'unlocks/new'
assert_have_selector '#errorExplanation'
assert_have_selector '#error_explanation'
assert_contain /Unlock token(.*)invalid/
end

Expand Down
6 changes: 3 additions & 3 deletions test/integration/recoverable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def reset_password(options={}, &block)

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
Expand All @@ -91,7 +91,7 @@ def reset_password(options={}, &block)

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
Expand All @@ -113,7 +113,7 @@ def reset_password(options={}, &block)
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
Expand Down
2 changes: 1 addition & 1 deletion test/integration/registerable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8db5591

Please sign in to comment.