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 +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/api_hammer/active_record_cache_find_by.rb +1 -1
- data/lib/api_hammer/version.rb +1 -1
- data/test/active_record_cache_find_by_test.rb +9 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99e31dd1684a1ad4d1b0ae026d71e1bea97be2aa
|
4
|
+
data.tar.gz: 4de47e712b79178f0bc475471710b84edc0659f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38b4eb2e9f73b1b3b924904400b485c19e086a5c499fb68abee994acd7ac113a5a8668ead73757f34948c74ae0a4c5387ddacf4ddad85f7bc80537af1fac2451
|
7
|
+
data.tar.gz: 4e1abf7ff0cecc5c1aead145d8c73e4eb792719da9a134b755596a153204f6564e6a6266acdafeee8854eff3f101ffa2f1e4f47545b24852b8ac058eb8503c42
|
data/CHANGELOG.md
CHANGED
@@ -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
|
data/lib/api_hammer/version.rb
CHANGED
@@ -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') }
|