From 81eae60dded98dbbc9bd44adb34c104833944ec6 Mon Sep 17 00:00:00 2001 From: Hamed Asghari Date: Tue, 13 Aug 2024 18:39:46 -0600 Subject: [PATCH] chore: Fix deprecation warnings --- spec/dummy/application.rb | 5 +++++ .../clearance/install/install_generator_spec.rb | 14 +++++--------- spec/support/generator_spec_helpers.rb | 11 +++++++++++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/spec/dummy/application.rb b/spec/dummy/application.rb index 884e27bc5..236f3d6ad 100644 --- a/spec/dummy/application.rb +++ b/spec/dummy/application.rb @@ -12,6 +12,11 @@ class Application < Rails::Application if Rails.version.match?(/(6.1|7.0)/) config.active_record.legacy_connection_handling = false end + + if Rails.gem_version >= Gem::Version.new("7.1") + config.active_support.cache_format_version = 7.0 + end + config.active_support.deprecation = :stderr config.eager_load = false diff --git a/spec/generators/clearance/install/install_generator_spec.rb b/spec/generators/clearance/install/install_generator_spec.rb index 8c50a8941..83ec4b6a9 100644 --- a/spec/generators/clearance/install/install_generator_spec.rb +++ b/spec/generators/clearance/install/install_generator_spec.rb @@ -2,10 +2,6 @@ require "generators/clearance/install/install_generator" describe Clearance::Generators::InstallGenerator, :generator do - def get_migration(path) - Pathname.new(migration_file(path)) - end - describe "initializer" do it "is copied to the application" do provide_existing_application_controller @@ -70,7 +66,7 @@ def get_migration(path) table_does_not_exist(:users) run_generator - migration = get_migration("db/migrate/create_users.rb") + migration = migration_file("db/migrate/create_users.rb") expect(migration).to exist expect(migration).to have_correct_syntax @@ -92,7 +88,7 @@ def get_migration(path) table_does_not_exist(:users) run_generator - migration = get_migration("db/migrate/create_users.rb") + migration = migration_file("db/migrate/create_users.rb") expect(migration).to exist expect(migration).to have_correct_syntax @@ -106,8 +102,8 @@ def get_migration(path) provide_existing_application_controller run_generator - create_migration = get_migration("db/migrate/create_users.rb") - add_migration = get_migration("db/migrate/add_clearance_to_users.rb") + create_migration = migration_file("db/migrate/create_users.rb") + add_migration = migration_file("db/migrate/add_clearance_to_users.rb") expect(create_migration).not_to exist expect(add_migration).not_to exist @@ -130,7 +126,7 @@ def get_migration(path) and_return(existing_indexes) run_generator - migration = get_migration("db/migrate/add_clearance_to_users.rb") + migration = migration_file("db/migrate/add_clearance_to_users.rb") expect(migration).to exist expect(migration).to have_correct_syntax diff --git a/spec/support/generator_spec_helpers.rb b/spec/support/generator_spec_helpers.rb index 9c296d72d..b04b957c0 100644 --- a/spec/support/generator_spec_helpers.rb +++ b/spec/support/generator_spec_helpers.rb @@ -3,6 +3,16 @@ require "ammeter/init" module GeneratorSpecHelpers + module FileMethods + def file(path) + Pathname.new(super) + end + + def migration_file(path) + Pathname.new(super) + end + end + TEMPLATE_PATH = File.expand_path("../../app_templates", __FILE__) def provide_existing_routes_file @@ -36,6 +46,7 @@ def copy_to_generator_root(destination, template) RSpec.configure do |config| config.include GeneratorSpecHelpers + config.prepend GeneratorSpecHelpers::FileMethods config.before(:example, :generator) do destination File.expand_path("../../../tmp", __FILE__)