I''m having trouble making my functional tests work.  I''m
trying to
simulate an action performed while a user is logged in, but it only
redirects me to the signin page as if no user was logged in.
Here''s my functional test:
  def test_signout_with_valid_user
    get :signout, {}, { :user => users(:jeff).id }
    assert_redirected_to home_path
  end
The first user in my users.yml fixtures file is named jeff, with an id
of 1.
Here''s my admin controller''s signout method:
  before_filter :check_authentication, :except => [:signin, :show,
:reset_passwords]
  def signout
    session[:user] = nil
    session[:intended_action] = nil
    redirect_to home_path
  end
Here''s my application.rb check_authentication method:
  def check_authentication
    unless session[:user]
      session[:intended_action] = params
      redirect_to signin_path
    end
  end
When I use the actual application, it works fine--I''m able to sign in,
sign out, everything works as expected.  But when I run the functional
test, I get:
test_signout_with_valid_user(AdminControllerTest)
[test/functional/admin_control
ler_test.rb:42]:
response is not a redirection to all of the options supplied
(redirection is <{"
action"=>"signin",
"controller"=>"admin"}>), difference:
<{"action"=>"index", "c
ontroller"=>"comics"}>
What am I doing wrong?  As far as I can tell, I''m following exactly how
it''s described in Agile Web Dev v2, page 194.
Any help would be great.  Thanks!
Jeff
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Use @request.session instead of parameters to #get. Jason On 2/8/07, Jeff Coleman <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > I''m having trouble making my functional tests work. I''m trying to > simulate an action performed while a user is logged in, but it only > redirects me to the signin page as if no user was logged in. > > Here''s my functional test: > > def test_signout_with_valid_user > get :signout, {}, { :user => users(:jeff).id } > assert_redirected_to home_path > end > > The first user in my users.yml fixtures file is named jeff, with an id > of 1. > > Here''s my admin controller''s signout method: > > before_filter :check_authentication, :except => [:signin, :show, > :reset_passwords] > > def signout > session[:user] = nil > session[:intended_action] = nil > redirect_to home_path > end > > Here''s my application.rb check_authentication method: > > def check_authentication > unless session[:user] > session[:intended_action] = params > redirect_to signin_path > end > end > > When I use the actual application, it works fine--I''m able to sign in, > sign out, everything works as expected. But when I run the functional > test, I get: > > test_signout_with_valid_user(AdminControllerTest) > [test/functional/admin_control > ler_test.rb:42]: > response is not a redirection to all of the options supplied > (redirection is <{" > action"=>"signin", "controller"=>"admin"}>), difference: > <{"action"=>"index", "c > ontroller"=>"comics"}> > > What am I doing wrong? As far as I can tell, I''m following exactly how > it''s described in Agile Web Dev v2, page 194. > > Any help would be great. Thanks! > > Jeff > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jason Roelofs wrote:> Use @request.session instead of parameters to #get. > > JasonThanks, that worked! Is the Agile Web Dev book outdated already? Sigh. Jeff -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
is using @request.session a workaround or is that the new correct
syntax?
is get :signout, {}, { :user => users(:jeff).id }  deprecated in
1.2.2?
i had read that get :signout, {}, { :user => users(:jeff).id }  not
working was a bug and will be fixed in 1.2.3, but if i shouldn''t be
using that syntax anyway because it is deprecated then i will move my
tests to the new syntax.
thank you, in advance.
On Feb 8, 2:35 pm, Jeff Coleman
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Jason Roelofs wrote:
> > Use @request.sessioninstead of parameters to #get.
>
> > Jason
>
> Thanks, that worked!
>
> Is the Agile Web Dev book outdated already?  Sigh.
>
> Jeff
>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
It''s a bug and will (is?) fixed in Rail 1.2.3 http://dev.rubyonrails.org/ticket/7372 Jason On 2/28/07, Thomas Mango <tsmango-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > is using @request.session a workaround or is that the new correct > syntax? > > is get :signout, {}, { :user => users(:jeff).id } deprecated in > 1.2.2? > > i had read that get :signout, {}, { :user => users(:jeff).id } not > working was a bug and will be fixed in 1.2.3, but if i shouldn''t be > using that syntax anyway because it is deprecated then i will move my > tests to the new syntax. > > thank you, in advance. > > On Feb 8, 2:35 pm, Jeff Coleman <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > Jason Roelofs wrote: > > > Use @request.sessioninstead of parameters to #get. > > > > > Jason > > > > Thanks, that worked! > > > > Is the Agile Web Dev book outdated already? Sigh. > > > > Jeff > > > > -- > > Posted viahttp://www.ruby-forum.com/. > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Okay, thank you. On 3/2/07, Jason Roelofs <jameskilton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> It''s a bug and will (is?) fixed in Rail 1.2.3 > > http://dev.rubyonrails.org/ticket/7372 > > Jason > > On 2/28/07, Thomas Mango <tsmango-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > is using @request.session a workaround or is that the new correct > > syntax? > > > > is get :signout, {}, { :user => users(:jeff).id } deprecated in > > 1.2.2? > > > > i had read that get :signout, {}, { :user => users(:jeff).id } not > > working was a bug and will be fixed in 1.2.3, but if i shouldn''t be > > using that syntax anyway because it is deprecated then i will move my > > tests to the new syntax. > > > > thank you, in advance. > > > > On Feb 8, 2:35 pm, Jeff Coleman < > rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > wrote: > > > Jason Roelofs wrote: > > > > Use @request.sessioninstead of parameters to #get. > > > > > > > Jason > > > > > > Thanks, that worked! > > > > > > Is the Agile Web Dev book outdated already? Sigh. > > > > > > Jeff > > > > > > -- > > > Posted viahttp://www.ruby-forum.com/. > > > > > > > > > > >-- Thomas Mango tsmango-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---