Skip to content

Commit

Permalink
Use _ instead of .
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Feb 8, 2010
1 parent 445070f commit 54cd2cc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/registrations_controller.rb
Expand Up @@ -7,7 +7,7 @@ def create
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
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/sessions_controller.rb
Expand Up @@ -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

Expand All @@ -30,4 +30,9 @@ def destroy
sign_out_and_redirect(resource_name)
end

protected

def resource_just_signed_up?
flash[:"#{resource_name}_signed_up"]
end
end
8 changes: 4 additions & 4 deletions test/integration/registerable_test.rb
Expand Up @@ -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)

Expand Down

0 comments on commit 54cd2cc

Please sign in to comment.