[Rails] Re: Are flash[] values kept between redirect actions in integration tests?
Wins Lin wrote in post #1111366:
> My question is, are flash values kept in integration test? Does it have
> to be "true" here or the above behavior is correct?
The Rails guide has a clear explanation of the flash:
http://guides.rubyonrails.org/action_controller_overview.html#the-flash
Yes, the flash message is available IN the following request, but not
after it. My bet is that your assertion is happening after that next
action has completed.
Take a look at the example in Section 5.2 in this guide:
http://guides.rubyonrails.org/testing.html#integration-testing
post_via_redirect "/login", :username => users(:avs).username,
:password => users(:avs).password
assert_equal '/welcome', path
assert_equal 'Welcome avs!', flash[:notice]
Notice there is no follow_redirect! before checking the flash. Your
flash is getting destroyed before you can assert it.
--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/785f0fe32fdfe9f0e31f472eeada26ea%40ruby-forum.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home