Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9151849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:54:09+00:00 2026-06-17T11:54:09+00:00

Given a functional test such as: def test_exciting_rails_upgrades login(m=users(:manager)) post :import_users_map_fields, :csv_file => fixture_file_upload(‘/users.csv’,

  • 0

Given a functional test such as:

def test_exciting_rails_upgrades
    login(m=users(:manager))

    post :import_users_map_fields, :csv_file => fixture_file_upload('/users.csv', 'text/csv')
    assert flash.empty?
    flash.discard
    # other goodies omitted

end

In Rails 2.3.2 there are no errors, however in 2.3.15 the error is:

    NoMethodError: undefined method `discard' for {}:Hash
    /test/functional/broken_upgrades.rb:119:in `test_exciting_rails_upgrades'

Why is flash a Hash class instead of a FlashHash?

From the source it looks like both 2.3.2 and 2.3.15 ActionPack files lib/action_controller/flash.rb create the FlashHash class and inherit from Hash. However what is shown in this functional test in both 2.3.2 and 2.3.15 is a Hash class, not a HashFlash, so one cannot call discard on it.

Can anyone else reproduce this error with 2.3.15 and flash.discard?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:54:11+00:00Added an answer on June 17, 2026 at 11:54 am

    Here are two test cases you can use to prove ActionController changes the type of ‘flash’ depending on whether or not it is already set.

    In my app, you cannot see :index unless you’re logged in, so in test_flash_is_now_a_flashhash you see that flash was set by the backend properly, while in test_flash_is_a_plain_hash it was not.

    def test_flash_is_a_plain_hash
      login(users(:permitted_user))
      get :index
      assert flash.instance_of?(Hash)
    end
    
    def test_flash_is_now_a_flashhash
      get :index
      assert_redirected_to :controller => "login"
      assert flash.instance_of?(ActionController::Flash::FlashHash)
    end
    

    You can see this for yourself in the ActionController::TestRequest code:

    def flash
        session['flash'] || {}
    end
    

    Update: This has been fixed in Rails branch 2-3-stable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Environment: ASP.net MVC: Given anonymous structure as such: var test = new { name
Given a structure such as below class A { int test; void f() {
Given the following classes: <?php class test{ static public function statfunc() { echo this
So given this input string: =?ISO-8859-1?Q?TEST=2C_This_Is_A_Test_of_Some_Encoding=AE?= And this function: private string DecodeSubject(string input) {
Given a function object, how can I get its signature? For example, for: def
Given a set of functions, such as: template<class A1> Void Go(A1 a); template<class A1,
Is there a good tool to generate unit test cases given say a .NET
I have setup a test database and console app to confirm the following: Given
Given: (function() { function Foo() { } $.extend(Foo.prototype, { bar: 'hasBeer' }); }) Is
Please tell me what will the call to given function return and how? The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.