diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 31613e46..b032ec3f 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -7,7 +7,7 @@ class RegistrationsController < ApplicationController self.resource = resource_class.new(params[resource_name]) if resource.save - flash[:"#{resource_name}.signed_up"] = true + flash[:"#{resource_name}_signed_up"] = true set_flash_message :notice, :signed_up sign_in_and_redirect(resource_name, resource) else diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index fc2fa96f..fd11a954 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -8,7 +8,7 @@ class SessionsController < ApplicationController def new Devise::FLASH_MESSAGES.each do |message| set_now_flash_message :alert, message if params.try(:[], message) == "true" - end unless flash[:"#{resource_name}.signed_up"] + end unless resource_just_signed_up? super end @@ -30,4 +30,9 @@ class SessionsController < ApplicationController sign_out_and_redirect(resource_name) end + protected + + def resource_just_signed_up? + flash[:"#{resource_name}_signed_up"] + end end diff --git a/test/integration/registerable_test.rb b/test/integration/registerable_test.rb index c1578238..bdccf0bc 100644 --- a/test/integration/registerable_test.rb +++ b/test/integration/registerable_test.rb @@ -31,15 +31,15 @@ class RegistrationTest < ActionController::IntegrationTest fill_in 'password confirmation', :with => 'new_user123' click_button 'Sign up' - assert_equal true, @controller.send(:flash)[:"user.signed_up"] + assert_equal true, @controller.send(:flash)[:"user_signed_up"] assert_equal "You have signed up successfully.", @controller.send(:flash)[:notice] # For some reason flash is not being set correctly, so instead of getting the # "signed_up" message we get the unconfirmed one. Seems to be an issue with # the internal redirect by the hook and the tests. -# follow_redirect! -# assert_contain 'You have signed up successfully.' -# assert_not_contain 'confirm your account' + # follow_redirect! + # assert_contain 'You have signed up successfully.' + # assert_not_contain 'confirm your account' assert_not warden.authenticated?(:user)