Skip to content

Rails 7.1 deprecation notice for cache_format_version in Rails test environmentΒ #114

@asgeo1

Description

@asgeo1

This line of code in this gem, is producing a deprecation warning with Rails 7.1

config.graphql_fragment_cache.store = :null_store

But only in the test environment.

DEPRECATION WARNING: Support for `config.active_support.cache_format_version = 6.1` has been deprecated and will be removed in Rails 7.2

It doesn't matter if you set config.active_support.cache_format_version = 7.1 in the Rails environment or intializer, the deprecation warning will still happen.

This is because that line of code is executing before Rails gets a chance to boot and set the correct cache_format_version.

If using RSpec, a possible workaround for now, is in rails_helper.rb to set the cache format version prior to the gem being loaded. e.g.

require "spec_helper"

# NOTE: this is a fix for graphql-fragment_cache, which is initializing it's own cache in the test environment
require "active_support/cache"
ActiveSupport::Cache.format_version = 7.1

require File.expand_path("../config/environment", __dir__)
require "rspec/rails"

RSpec.configure do |config|
  ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions