From 97719a016250246dffe0ab55b40e385144726928 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Tue, 5 May 2020 12:28:08 +0200 Subject: [PATCH] Clear some warnings and test against Ruby 2.7 --- .rubocop.yml | 2 +- .travis.yml | 1 + dev.yml | 5 ++++- identity_cache.gemspec | 2 +- test/attribute_cache_test.rb | 6 +++--- test/fetch_multi_test.rb | 2 +- test/lazy_load_associated_classes_test.rb | 2 +- test/prefetch_associations_test.rb | 10 +++++----- 8 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index fb709886..e9f70da9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,4 +2,4 @@ inherit_from: - https://shopify.github.io/ruby-style-guide/rubocop.yml AllCops: - TargetRubyVersion: 2.6 + TargetRubyVersion: 2.4 diff --git a/.travis.yml b/.travis.yml index e0821205..d37b369b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: ruby rvm: - 2.4 - 2.6 + - 2.7 gemfile: - gemfiles/Gemfile.rails52 diff --git a/dev.yml b/dev.yml index c41a870f..2f16955b 100644 --- a/dev.yml +++ b/dev.yml @@ -3,7 +3,10 @@ name: identity-cache up: - homebrew: - postgresql - - ruby: 2.4.10 + - mysql-client@5.7: + or: [mysql@5.7] + conflicts: [mysql-connector-c, mysql, mysql-client] + - ruby: 2.6.5 - railgun - bundler diff --git a/identity_cache.gemspec b/identity_cache.gemspec index 7a57a785..37650dd8 100644 --- a/identity_cache.gemspec +++ b/identity_cache.gemspec @@ -48,7 +48,7 @@ Gem::Specification.new do |gem| else gem.add_development_dependency('cityhash', '0.6.0') gem.add_development_dependency('mysql2') - gem.add_development_dependency('pg', '~> 0.18') + gem.add_development_dependency('pg') gem.add_development_dependency('stackprof') end end diff --git a/test/attribute_cache_test.rb b/test/attribute_cache_test.rb index e4990b7b..d2600fb1 100644 --- a/test/attribute_cache_test.rb +++ b/test/attribute_cache_test.rb @@ -80,16 +80,16 @@ def test_cached_attribute_values_are_expired_from_the_cache_when_a_new_record_is def test_value_coercion assert_queries(1) { assert_equal 'foo', AssociatedRecord.fetch_name_by_id(@record.id.to_f) } assert_no_queries { assert_equal 'foo', AssociatedRecord.fetch_name_by_id(@record.id) } - @record.update_attributes!(name: 'bar') + @record.update!(name: 'bar') assert_queries(1) { assert_equal 'bar', AssociatedRecord.fetch_name_by_id(@record.id.to_f) } end def test_no_nil_empty_string_cache_key_conflict Item.cache_attribute(:id, by: [:title]) - @parent.update_attributes!(title: "") + @parent.update!(title: "") assert_queries(1) { assert_equal @parent.id, Item.fetch_id_by_title("") } assert_queries(1) { assert_nil Item.fetch_id_by_title(nil) } - @parent.update_attributes!(title: nil) + @parent.update!(title: nil) assert_queries(1) { assert_nil Item.fetch_id_by_title("") } assert_queries(1) { assert_equal @parent.id, Item.fetch_id_by_title(nil) } end diff --git a/test/fetch_multi_test.rb b/test/fetch_multi_test.rb index 48d2259f..ceebdf92 100644 --- a/test/fetch_multi_test.rb +++ b/test/fetch_multi_test.rb @@ -270,7 +270,7 @@ def test_fetch_multi_after_expiring_a_record def test_fetch_multi_id_coercion assert_equal(@joe.title, Item.fetch_multi(@joe.id.to_f).first.title) - @joe.update_attributes!(title: "#{@joe.title} changed") + @joe.update!(title: "#{@joe.title} changed") assert_equal(@joe.title, Item.fetch_multi(@joe.id.to_f).first.title) end diff --git a/test/lazy_load_associated_classes_test.rb b/test/lazy_load_associated_classes_test.rb index 3b7eccc0..9651aed5 100644 --- a/test/lazy_load_associated_classes_test.rb +++ b/test/lazy_load_associated_classes_test.rb @@ -28,7 +28,7 @@ def test_cache_invalidation assert_queries(0) do assert_equal 'baz', Item.fetch(item.id).fetch_associated_records.first.name end - associated_record.update_attributes!(name: 'buzz') + associated_record.update!(name: 'buzz') assert_queries(2) do assert_equal 'buzz', Item.fetch(item.id).fetch_associated_records.first.name end diff --git a/test/prefetch_associations_test.rb b/test/prefetch_associations_test.rb index 031908e4..da634fe2 100644 --- a/test/prefetch_associations_test.rb +++ b/test/prefetch_associations_test.rb @@ -80,8 +80,8 @@ def test_prefetch_associations_without_using_cache def test_prefetch_associations_cached_belongs_to Item.send(:cache_belongs_to, :item) - @bob.update_attributes!(item_id: @joe.id) - @joe.update_attributes!(item_id: @fred.id) + @bob.update!(item_id: @joe.id) + @joe.update!(item_id: @fred.id) @bob.fetch_item @joe.fetch_item items = [@bob, @joe].map(&:reload) @@ -101,8 +101,8 @@ def test_prefetch_associations_cached_belongs_to def test_prefetch_associations_notifies_about_hydration Item.send(:cache_belongs_to, :item) - @bob.update_attributes!(item_id: @joe.id) - @joe.update_attributes!(item_id: @fred.id) + @bob.update!(item_id: @joe.id) + @joe.update!(item_id: @fred.id) @bob.fetch_item @joe.fetch_item items = [@bob, @joe].map(&:reload) @@ -119,7 +119,7 @@ def test_prefetch_associations_notifies_about_hydration def test_prefetch_associations_with_nil_cached_belongs_to Item.send(:cache_belongs_to, :item) - @bob.update_attributes!(item_id: 1234) + @bob.update!(item_id: 1234) assert_nil(@bob.fetch_item) assert_no_queries do