From 727b8dd5c2ad296aa0800118865640094903b983 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 23 Nov 2023 09:56:48 +0100 Subject: [PATCH 1/6] Bump Mocha For compatibility with recent minitest --- identity_cache.gemspec | 2 +- test/load_strategy/multi_load_request_test.rb | 2 +- test/test_helper.rb | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/identity_cache.gemspec b/identity_cache.gemspec index e2237738..caae45e4 100644 --- a/identity_cache.gemspec +++ b/identity_cache.gemspec @@ -39,7 +39,7 @@ Gem::Specification.new do |gem| gem.add_dependency("ar_transaction_changes", "~> 1.1") gem.add_development_dependency("minitest", "~> 5.14") - gem.add_development_dependency("mocha", "~> 1.12") + gem.add_development_dependency("mocha", "~> 2.0") gem.add_development_dependency("rake", "~> 13.0") gem.add_development_dependency("spy", "~> 1.0") end diff --git a/test/load_strategy/multi_load_request_test.rb b/test/load_strategy/multi_load_request_test.rb index ad31c56c..94aec97d 100644 --- a/test/load_strategy/multi_load_request_test.rb +++ b/test/load_strategy/multi_load_request_test.rb @@ -20,7 +20,7 @@ def test_after_load id = n.next letter = ("a".."z").to_a[n].to_sym callback = proc {} - callback.expects(:call).with(id => letter) + callback.expects(:call).with({ id => letter }) LoadRequest.new([id], callback) end multi_load_request = MultiLoadRequest.new(load_requests) diff --git a/test/test_helper.rb b/test/test_helper.rb index 17f4366b..b81a6944 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -15,7 +15,6 @@ DatabaseConnection.setup CacheConnection.setup -MiniTest::Test = MiniTest::Unit::TestCase unless defined?(MiniTest::Test) module IdentityCache class TestCase < Minitest::Test include ActiveRecordObjects From 7cab9102ae2913acc992aa34b4df811c9ecc775d Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 23 Nov 2023 10:03:28 +0100 Subject: [PATCH 2/6] Bump minimum Ruby and Active Record requirements --- .github/workflows/ci.yml | 2 +- gemfiles/Gemfile.min-supported | 4 ++-- identity_cache.gemspec | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 049e62c8..1e3f3435 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: matrix: entry: - name: 'Minimum supported' - ruby: '2.7' + ruby: '3.0' gemfile: "Gemfile.min-supported" - name: 'Latest released & run rubocop' ruby: '3.2' diff --git a/gemfiles/Gemfile.min-supported b/gemfiles/Gemfile.min-supported index 8c85d373..71244242 100644 --- a/gemfiles/Gemfile.min-supported +++ b/gemfiles/Gemfile.min-supported @@ -3,8 +3,8 @@ gemspec path: ".." gem "ar_transaction_changes", "~> 1.1.0" -gem "activerecord", "~> 5.2.0" -gem "mysql2", "~> 0.4.4" +gem "activerecord", "~> 7.0.0" +gem "mysql2", "~> 0.5" gem "pg", "~> 0.18.0" gem "memcached", "~> 1.8.0" gem "memcached_store", "~> 1.0.0" diff --git a/identity_cache.gemspec b/identity_cache.gemspec index caae45e4..c57fa8fb 100644 --- a/identity_cache.gemspec +++ b/identity_cache.gemspec @@ -31,11 +31,11 @@ Gem::Specification.new do |gem| gem.require_paths = ["lib"] gem.version = IdentityCache::VERSION - gem.required_ruby_version = ">= 2.5.0" + gem.required_ruby_version = ">= 3.0.0" gem.metadata["allowed_push_host"] = "https://rubygems.org" - gem.add_dependency("activerecord", ">= 5.2") + gem.add_dependency("activerecord", ">= 7.0") gem.add_dependency("ar_transaction_changes", "~> 1.1") gem.add_development_dependency("minitest", "~> 5.14") From 8315e4e5efd9f7fc41086170d3922f24ea78b444 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 23 Nov 2023 10:16:43 +0100 Subject: [PATCH 3/6] Use Ruby 3.2.2 in development --- dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev.yml b/dev.yml index 602741a5..50b8e923 100644 --- a/dev.yml +++ b/dev.yml @@ -5,7 +5,7 @@ up: - mysql-client@5.7: or: [mysql@5.7] conflicts: [mysql-connector-c, mysql, mysql-client] - - ruby: 3.2.0 + - ruby: 3.2.2 - isogun - bundler From c2b6d9f9caf1fff0b32770631ae763f411d43e49 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 23 Nov 2023 10:29:18 +0100 Subject: [PATCH 4/6] Update mocks for Rails 7+ --- test/fetch_test.rb | 2 +- test/index_cache_test.rb | 2 +- test/test_helper.rb | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/fetch_test.rb b/test/fetch_test.rb index 08b4d06d..612fbdce 100644 --- a/test/fetch_test.rb +++ b/test/fetch_test.rb @@ -238,7 +238,7 @@ def test_fetch_by_title_hit end # Id not found, use sql, SELECT id FROM records WHERE title = '...' LIMIT 1" - Item.connection.expects(:exec_query).returns(ActiveRecord::Result.new(["id"], [[1]])) + Item.connection.expects(ar_query_method(Item.connection)).returns(ActiveRecord::Result.new(["id"], [[1]])) result = Item.fetch_by_title("bob") assert_instance_of(Item, result) diff --git a/test/index_cache_test.rb b/test/index_cache_test.rb index f2892239..f80bd6cd 100644 --- a/test/index_cache_test.rb +++ b/test/index_cache_test.rb @@ -34,7 +34,7 @@ def test_fetch_with_garbage_input def test_fetch_with_unique_adds_limit_clause Item.cache_index(:title, :id, unique: true) - Item.connection.expects(:exec_query) + Item.connection.expects(ar_query_method(Item.connection)) .with(regexp_matches(/ LIMIT [1?]\Z/i), any_parameters) .returns(ActiveRecord::Result.new([], [])) diff --git a/test/test_helper.rb b/test/test_helper.rb index b81a6944..86f36b62 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -42,6 +42,14 @@ def teardown private + def ar_query_method(connection) + if connection.respond_to?(:internal_exec_query, true) + :internal_exec_query + else + :exec_query + end + end + def create(class_symbol) class_symbol.to_s.classify.constantize.create! end From dc412c329f9fd4dc2caddabea9259e664fa14654 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 23 Nov 2023 10:44:43 +0100 Subject: [PATCH 5/6] Update pg --- gemfiles/Gemfile.min-supported | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gemfiles/Gemfile.min-supported b/gemfiles/Gemfile.min-supported index 71244242..9c76f4b1 100644 --- a/gemfiles/Gemfile.min-supported +++ b/gemfiles/Gemfile.min-supported @@ -5,7 +5,7 @@ gem "ar_transaction_changes", "~> 1.1.0" gem "activerecord", "~> 7.0.0" gem "mysql2", "~> 0.5" -gem "pg", "~> 0.18.0" +gem "pg", "~> 1.1" gem "memcached", "~> 1.8.0" gem "memcached_store", "~> 1.0.0" gem "dalli", "~> 2.7.11" From 8f48924242772c4470958356921b4451da11c1c1 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 23 Nov 2023 10:53:31 +0100 Subject: [PATCH 6/6] Update minimum memcached_store --- Gemfile | 2 +- gemfiles/Gemfile.min-supported | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 58ce7e67..9b8ee48c 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ gem "rubocop-shopify", "~> 2.9.0", require: false gem "mysql2", "~> 0.5.3", platform: :mri gem "pg", ">= 0.18", "< 2.0", platform: :mri gem "memcached", "~> 1.8.0", platform: :mri -gem "memcached_store", "~> 1.0.0", platform: :mri +gem "memcached_store", "~> 2.3.2", platform: :mri gem "dalli", "~> 2.7.11" gem "cityhash", "~> 0.6.0", platform: :mri diff --git a/gemfiles/Gemfile.min-supported b/gemfiles/Gemfile.min-supported index 9c76f4b1..16ffb3fa 100644 --- a/gemfiles/Gemfile.min-supported +++ b/gemfiles/Gemfile.min-supported @@ -7,6 +7,6 @@ gem "activerecord", "~> 7.0.0" gem "mysql2", "~> 0.5" gem "pg", "~> 1.1" gem "memcached", "~> 1.8.0" -gem "memcached_store", "~> 1.0.0" +gem "memcached_store", "~> 2.3.2" gem "dalli", "~> 2.7.11" gem "cityhash", "~> 0.6.0"