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 4057230
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:55:36+00:00 2026-05-20T14:55:36+00:00

Generally, I want my functional tests to not perform action caching. Rails seems to

  • 0

Generally, I want my functional tests to not perform action caching. Rails seems to be on my side, defaulting to config.action_controller.perform_caching = false in environment/test.rb. This leads to normal functional tests not testing the caching.

So how do I test caching in Rails 3.

The solutions proposed in this thread seem rather hacky or taylored towards Rails 2:
How to enable page caching in a functional test in rails?

I want to do something like:

test "caching of index method" do
  with_caching do
    get :index
    assert_template 'index'
    get :index
    assert_template ''
  end
end

Maybe there is also a better way of testing that the cache was hit?

  • 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-05-20T14:55:37+00:00Added an answer on May 20, 2026 at 2:55 pm

    You’re liable to end up with tests stomping on each other. You should wrap this up with ensure and reset it to old values appropriately. An example:

    module ActionController::Testing::Caching
      def with_caching(on = true)
        caching = ActionController::Base.perform_caching
        ActionController::Base.perform_caching = on
        yield
      ensure
        ActionController::Base.perform_caching = caching
      end
    
      def without_caching(&block)
        with_caching(false, &block)
      end
    end
    

    I’ve also put this into a module so you can just include this in your test class or parent class.

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

Sidebar

Related Questions

It seems I still don't get generics ... I want a general function to
Generally whenever i want to push in the changes to remote Git i follow
When I want to update controls across threads this is how I generally end
I have an EditText, which generally shows parallel to the screen X-axis. I want
I want to ‪reduce‬ the CPU usage/ROM usage/RAM usage - generally‬, all system resources
I want to get an onload event working on my config object. The following
In F# I want to perform unit testing on a function with several levels
We want to compare general performance (CPU, I/O, network, ...) of different JVMs for
I want to make a general error handling package that should be called from
I want to know the General formula for Writing Regular Expression? Any article?

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.