#287 new
yinhm

have_flash failed after upgrade to rails-2.3.4

Reported by yinhm | September 7th, 2009 @ 02:26 AM

This problem probably due to rails 2.3.4 changed session[flash] init:


152 160         # to put a new one. 
153 161         def flash #:doc: 
154               unless defined? @_flash 
155                 @_flash = session["flash"] ||= FlashHash.new 
    162           if !defined?(@_flash) 
    163             @_flash = session["flash"] || FlashHash.new 
156 164             @_flash.sweep 
157 165           end

I didn't look it future how session["flash"] got initialize and stored cause I not a rails core expect.

Comments and changes to this ticket

  • Martin Rehfeld

    Martin Rehfeld September 10th, 2009 @ 09:46 AM

    • Tag set to bug, cucumber, flash, have_tag, response, webrat

    Got bitten by the same problem today; flash messages just don't make it into the rendered response anymore causing many webrat based tests to fail.

    I hope a fix can be provided soon.

  • Martin Rehfeld

    Martin Rehfeld September 24th, 2009 @ 05:36 AM

    • Assigned user set to “Bryan Helmkamp”

    Let me provide a little more context of at least my environment:

    • works fine with Rails 2.3.2, fails with 2.3.4
    • Webrat is installed as a plugin from github and is at version 4.4.4+ (History.txt lists two "minor enhancements" beyond 4.4.4)
    • Webrat is driven in "Rails mode" by Cucumber (version 0.3.1+)
    • when flash[:somekey] is accessed in any assertion (Cucumber step definition) it will always return nil
    • thus flash messages are never rendered into any output making various assertions fail
    • as Yinhaiming pointed out there are indeed changes in the Rails flash code (the diff above is from actionpack/lib/action_controller/flash.rb), but I do not see how this would be related to the problem at hand

    I am happy to provide any additional info or perform recommended steps to get a hold on this nasty little bug fellow.

  • Martin Rehfeld

    Martin Rehfeld September 26th, 2009 @ 10:33 AM

    even more info:
    * the problem persists even when I update my webrat plugin to the laster HEAD from github (History.txt: 0.6.rc1 / 2009-09-22) * and also persists when I additionally update the cucumber plugin to HEAD (2009-09-24)

  • oey (at ubilabs)

    oey (at ubilabs) December 17th, 2009 @ 11:09 AM

    I had the same problem using Webrat, Rails2.3.4 and Restful-Authentication. The problem seems to be caused by this code used to "allow exceptions to come through":


    ActionController::Base.class_eval do
    def perform_action

    {mkd-extraction-f7a0925f54b65c0bd31dc2cf2b72bbf4}

    end end

    Together the changes mentioned above in the Rails-Core:

    http://github.com/rails/rails/commit/dc94c095031036ffc0f9ac0ee98a11...

    and

    http://github.com/rails/rails/commit/8736dd324117af90e0bf120cfd2074...

    the perform_action_with_flash will never be called and the flash is not saved in the session. I added the necessary flash storing stuff to the code mentioned above to solve the problem but that feels quite messy....


    ActionController::Base.class_eval do
    def perform_action

    {mkd-extraction-aa97187f8af536613bc5f592bbab7779}

    end end

  • oey (at ubilabs)

    oey (at ubilabs) December 17th, 2009 @ 11:14 AM

    wtf happens to the posted code?

  • Martin Rehfeld

    Martin Rehfeld December 17th, 2009 @ 11:44 AM

    Hi oey,

    whatever happened to your code snippets made them completely unreadable...

    Maybe you could put them on gist and links to in your comment?

    So you are saying this is in fact a restful authentication problem (the mentioned code coming from rest_auth_features_helper.rb)? This is a very good lead! I have restful_authentication in my project as well!

    Cheers,
    Martin

  • oey (at ubilabs)
  • Scott Johnson

    Scott Johnson June 4th, 2010 @ 01:12 PM

    I am getting the same symptoms after upgrading from Rails 2.3.5 to 2.3.8.

    I'm not using restful_authentication. I am using authlogic; perhaps it shares some code?

    Everything works when I use Rails 2.3.5, webrat 0.6.0, and cucumber 0.5.0.
    It also works with Rails 2.3.5, webrat 0.7.1, and cucumber 0.7.3.

    It fails with Rails 2.3.8 with either of the above combinations of webrat+cucumber.

  • Scott Johnson

    Scott Johnson June 4th, 2010 @ 01:19 PM

    Also I tried the change in the gist linked above, but I'm not sure I changed the right file. I patched some file in the webrat source, is that right? Anyway it didn't seem to affect anything.

  • Martin Rehfeld

    Martin Rehfeld June 4th, 2010 @ 02:10 PM

    The file you need to change was generated by restful_authentication and put in your project directory, probably at

    features/step_definitions/rest_auth_features_helper.rb
    
  • Scott Johnson

    Scott Johnson June 4th, 2010 @ 02:45 PM

    Unfortunately that code doesn't exist anywhere in my app's source tree.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

Pages