Skip to content

Commit

Permalink
Clear some warnings and test against Ruby 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed May 5, 2020
1 parent daaba73 commit 97719a0
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ inherit_from:
- https://shopify.github.io/ruby-style-guide/rubocop.yml

AllCops:
TargetRubyVersion: 2.6
TargetRubyVersion: 2.4
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: ruby
rvm:
- 2.4
- 2.6
- 2.7

gemfile:
- gemfiles/Gemfile.rails52
Expand Down
5 changes: 4 additions & 1 deletion dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ name: identity-cache
up:
- homebrew:
- postgresql
- ruby: 2.4.10
- [email protected]:
or: [[email protected]]
conflicts: [mysql-connector-c, mysql, mysql-client]
- ruby: 2.6.5
- railgun
- bundler

Expand Down
2 changes: 1 addition & 1 deletion identity_cache.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions test/attribute_cache_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/fetch_multi_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/lazy_load_associated_classes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions test/prefetch_associations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 97719a0

Please sign in to comment.