Fix a bug in Devise::TestHelpers where current_user was returning a Response object for non active accounts, closes #341.
This commit is contained in:
parent
4db3ac820b
commit
4b272767d6
|
@ -1,3 +1,6 @@
|
|||
* bug fix
|
||||
* Fix a bug in Devise::TestHelpers where current_user was returning a Response object for non active accounts;
|
||||
|
||||
== 1.1.rc2
|
||||
|
||||
* enhancements
|
||||
|
@ -16,7 +19,7 @@
|
|||
* devise.mailer.user.confirmations_instructions now should be devise.mailer.confirmations_instructions.user_subject
|
||||
* Generators now use Rails 3 syntax (devise:install) instead of devise_install
|
||||
|
||||
== 1.1.rc
|
||||
== 1.1.rc1
|
||||
|
||||
* enhancements
|
||||
* Rails 3 compatibility
|
||||
|
|
|
@ -42,6 +42,8 @@ module Devise
|
|||
status, headers, body = Devise::FailureApp.call(env).to_a
|
||||
@controller.send :render, :status => status, :text => body,
|
||||
:content_type => headers["Content-Type"], :location => headers["Location"]
|
||||
|
||||
nil
|
||||
else
|
||||
result
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class UsersController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
before_filter :authenticate_user!, :except => :show
|
||||
respond_to :html, :xml
|
||||
|
||||
def index
|
||||
|
@ -7,6 +7,10 @@ class UsersController < ApplicationController
|
|||
respond_with(current_user)
|
||||
end
|
||||
|
||||
def show
|
||||
@current_user = current_user
|
||||
end
|
||||
|
||||
def expire
|
||||
user_session['last_request_at'] = 31.minutes.ago.utc
|
||||
render :text => 'User will be expired on next request'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Rails::Application.routes.draw do
|
||||
resources :users, :only => [:index] do
|
||||
resources :users, :only => [:index, :show] do
|
||||
get :expire, :on => :member
|
||||
end
|
||||
|
||||
|
|
|
@ -10,14 +10,28 @@ class TestHelpersTest < ActionController::TestCase
|
|||
assert_equal "You need to sign in or sign up before continuing.", flash[:alert]
|
||||
end
|
||||
|
||||
test "redirects if attempting to access a page with a unconfirmed account" do
|
||||
test "redirects if attempting to access a page with an unconfirmed account" do
|
||||
swap Devise, :confirm_within => 0 do
|
||||
sign_in create_user
|
||||
user = create_user
|
||||
assert !user.active?
|
||||
|
||||
sign_in user
|
||||
get :index
|
||||
assert_redirected_to new_user_session_path
|
||||
end
|
||||
end
|
||||
|
||||
test "returns nil if accessing current_user with an unconfirmed account" do
|
||||
swap Devise, :confirm_within => 0 do
|
||||
user = create_user
|
||||
assert !user.active?
|
||||
|
||||
sign_in user
|
||||
get :show, :id => user
|
||||
assert_nil assigns(:current_user)
|
||||
end
|
||||
end
|
||||
|
||||
test "does not redirect with valid user" do
|
||||
user = create_user
|
||||
user.confirm!
|
||||
|
|
Loading…
Reference in New Issue