From cbc6926e3dc1699f8e9274ce180f4018fb7afdf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 28 Jun 2012 12:05:20 +0200 Subject: [PATCH] Fix issue #1928, thanks to @ejfinneran for a test case --- Gemfile.lock | 2 +- lib/devise/test_helpers.rb | 1 + test/test_helpers_test.rb | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 43812a64..fdadc96a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -87,7 +87,7 @@ GEM omniauth-openid (1.0.1) omniauth (~> 1.0) rack-openid (~> 1.3.1) - orm_adapter (0.1.0) + orm_adapter (0.3.0) polyglot (0.3.3) rack (1.4.1) rack-cache (1.2) diff --git a/lib/devise/test_helpers.rb b/lib/devise/test_helpers.rb index e1f890d9..9aa7c239 100644 --- a/lib/devise/test_helpers.rb +++ b/lib/devise/test_helpers.rb @@ -45,6 +45,7 @@ module Devise def sign_in(resource_or_scope, resource=nil) scope ||= Devise::Mapping.find_scope!(resource_or_scope) resource ||= resource_or_scope + warden.instance_variable_get(:@users).delete(scope) warden.session_serializer.store(resource, scope) end diff --git a/test/test_helpers_test.rb b/test/test_helpers_test.rb index b3905c1e..ff4a1677 100644 --- a/test/test_helpers_test.rb +++ b/test/test_helpers_test.rb @@ -47,6 +47,18 @@ class TestHelpersTest < ActionController::TestCase assert_response :success end + test "does not redirect with valid user after failed first attempt" do + get :index + assert_response :redirect + + user = create_user + user.confirm! + + sign_in user + get :index + assert_response :success + end + test "redirects if valid user signed out" do user = create_user user.confirm!