api_hammer 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47d49032018338bda7b3582ad0ee4ced9872023f
4
- data.tar.gz: f29e3cddca5d09853af22dabeec7f1aaaa3bc809
3
+ metadata.gz: 99e31dd1684a1ad4d1b0ae026d71e1bea97be2aa
4
+ data.tar.gz: 4de47e712b79178f0bc475471710b84edc0659f8
5
5
  SHA512:
6
- metadata.gz: 25525ad6d1eda4cbb4d9b61cbcf270a91255fa10278bb89774cdabdafb85d4a5ef591f5d9725759d557a3763ac1fbbbc148e394242cc562b8ad97e938ebdf8bd
7
- data.tar.gz: 6ac7d6ea07947ed9a6b5dbf0a6a407d3e275cf53b762fdf7a0ff031422cbf3c832e7b9a2c8e1b7258d58ebf90a631bc9e616418aea619d1e8488120320115cad
6
+ metadata.gz: 38b4eb2e9f73b1b3b924904400b485c19e086a5c499fb68abee994acd7ac113a5a8668ead73757f34948c74ae0a4c5387ddacf4ddad85f7bc80537af1fac2451
7
+ data.tar.gz: 4e1abf7ff0cecc5c1aead145d8c73e4eb792719da9a134b755596a153204f6564e6a6266acdafeee8854eff3f101ffa2f1e4f47545b24852b8ac058eb8503c42
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 0.3.2
2
+ - ActiveRecord::Base.cache_find_by support finding on associations, fix bind detection with symbols
3
+
1
4
  # 0.3.1
2
5
  - bugfix ActiveRecord::Base.cache_find_by
3
6
 
@@ -23,7 +23,7 @@ module ActiveRecord
23
23
  def one_record_with_caching(can_cache = true)
24
24
  actual_right = proc do |where_value|
25
25
  if where_value.right.is_a?(Arel::Nodes::BindParam)
26
- column, value = bind_values.detect { |(column, value)| column.name == where_value.left.name }
26
+ column, value = bind_values.detect { |(column, value)| column.name.to_s == where_value.left.name.to_s }
27
27
  value
28
28
  else
29
29
  where_value.right
@@ -1,3 +1,3 @@
1
1
  module ApiHammer
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -36,6 +36,7 @@ class Album < ActiveRecord::Base
36
36
  cache_find_by(:performer)
37
37
  cache_find_by(:title, :performer)
38
38
  cache_find_by(:tracks)
39
+ cache_find_by(:catalog_xid, :title)
39
40
  end
40
41
 
41
42
  class Catalog < ActiveRecord::Base
@@ -63,6 +64,7 @@ describe 'ActiveRecord::Base.cache_find_by' do
63
64
 
64
65
  after do
65
66
  Album.all.each(&:destroy)
67
+ Catalog.all.each(&:destroy)
66
68
  end
67
69
 
68
70
  it('caches #find by primary key') do
@@ -157,6 +159,13 @@ describe 'ActiveRecord::Base.cache_find_by' do
157
159
  assert_caches("cache_find_by/albums/performer/y/title/x") { assert Album.where(:title => 'x', :performer => 'y').first }
158
160
  end
159
161
 
162
+ it('caches with two attributes on an association with a where') do
163
+ c = Catalog.create!
164
+ Album.create!(:title => 'x', :performer => 'y', :catalog_xid => c.id)
165
+ c = Catalog.first
166
+ assert_caches("cache_find_by/albums/catalog_xid/#{c.id}/title/x") { assert c.albums.where(:title => 'x').first }
167
+ end
168
+
160
169
  it('flushes cache on save') do
161
170
  album = Album.create!(:title => 'x', :performer => 'y')
162
171
  assert_caches(key1 = "cache_find_by/albums/performer/y/title/x") { assert Album.find_by_title_and_performer('x', 'y') }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_hammer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan