active_remote-cached 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +85 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +58 -0
- data/Appraisals +27 -0
- data/Gemfile +2 -0
- data/README.md +121 -0
- data/Rakefile +6 -9
- data/active_remote-cached.gemspec +52 -21
- data/lib/active_remote/cached/argument_keys.rb +83 -46
- data/lib/active_remote/cached/cache.rb +78 -51
- data/lib/active_remote/cached/railtie.rb +5 -5
- data/lib/active_remote/cached/version.rb +3 -1
- data/lib/active_remote/cached.rb +159 -112
- data/lib/active_remote-cached.rb +3 -1
- data/spec/active_remote/cached/argument_keys_spec.rb +136 -10
- data/spec/active_remote/cached/cache_spec.rb +179 -16
- data/spec/active_remote/cached_delete_methods_spec.rb +66 -12
- data/spec/active_remote/cached_exist_methods_spec.rb +111 -33
- data/spec/active_remote/cached_find_methods_spec.rb +62 -51
- data/spec/active_remote/cached_search_methods_spec.rb +202 -102
- data/spec/active_remote/cached_spec.rb +331 -0
- data/spec/spec_helper.rb +6 -10
- metadata +76 -22
|
@@ -1,130 +1,208 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
class ExistMethodClass
|
|
4
6
|
include ::ActiveRemote::Cached
|
|
5
7
|
|
|
6
|
-
def self.find
|
|
7
|
-
|
|
8
|
+
def self.find(*)
|
|
9
|
+
:record
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.search(*)
|
|
13
|
+
[:record]
|
|
14
|
+
end
|
|
8
15
|
|
|
9
16
|
cached_finders_for :guid
|
|
10
17
|
cached_finders_for :guid, :user_guid
|
|
11
|
-
cached_finders_for [
|
|
12
|
-
cached_finders_for [
|
|
18
|
+
cached_finders_for %i[user_guid client_guid]
|
|
19
|
+
cached_finders_for %i[derp user_guid client_guid]
|
|
13
20
|
end
|
|
14
21
|
|
|
15
22
|
describe ExistMethodClass do
|
|
16
|
-
describe
|
|
23
|
+
describe 'API' do
|
|
17
24
|
it "creates 'cached_exist_find_by_guid'" do
|
|
18
|
-
ExistMethodClass.
|
|
25
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_find_by_guid)
|
|
19
26
|
end
|
|
20
27
|
|
|
21
28
|
it "creates 'cached_exist_search_by_guid'" do
|
|
22
|
-
ExistMethodClass.
|
|
29
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_search_by_guid)
|
|
23
30
|
end
|
|
24
31
|
|
|
25
32
|
it "creates 'cached_exist_find_by_user_guid'" do
|
|
26
|
-
ExistMethodClass.
|
|
33
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_find_by_user_guid)
|
|
27
34
|
end
|
|
28
35
|
|
|
29
36
|
it "creates 'cached_exist_search_by_user_guid'" do
|
|
30
|
-
ExistMethodClass.
|
|
37
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_search_by_user_guid)
|
|
31
38
|
end
|
|
32
39
|
|
|
33
40
|
it "creates 'cached_exist_find_by_user_guid_and_client_guid'" do
|
|
34
|
-
ExistMethodClass.
|
|
41
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_find_by_user_guid_and_client_guid)
|
|
35
42
|
end
|
|
36
43
|
|
|
37
44
|
it "creates 'cached_exist_search_by_user_guid_and_client_guid'" do
|
|
38
|
-
ExistMethodClass.
|
|
45
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_search_by_user_guid_and_client_guid)
|
|
39
46
|
end
|
|
40
47
|
|
|
41
48
|
it "creates 'cached_exist_find_by_client_guid_and_user_guid'" do
|
|
42
|
-
ExistMethodClass.
|
|
49
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_find_by_client_guid_and_user_guid)
|
|
43
50
|
end
|
|
44
51
|
|
|
45
52
|
it "creates 'cached_exist_search_by_client_guid_and_user_guid'" do
|
|
46
|
-
ExistMethodClass.
|
|
53
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_search_by_client_guid_and_user_guid)
|
|
47
54
|
end
|
|
48
55
|
|
|
49
56
|
it "creates 'cached_exist_find_by_derp_and_user_guid_and_client_guid'" do
|
|
50
|
-
ExistMethodClass.
|
|
57
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_find_by_derp_and_user_guid_and_client_guid)
|
|
51
58
|
end
|
|
52
59
|
|
|
53
60
|
it "creates 'cached_exist_search_by_derp_and_user_guid_and_client_guid'" do
|
|
54
|
-
ExistMethodClass.
|
|
61
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_search_by_derp_and_user_guid_and_client_guid)
|
|
55
62
|
end
|
|
56
63
|
|
|
57
64
|
it "creates 'cached_exist_find_by_client_guid_and_derp_and_user_guid'" do
|
|
58
|
-
ExistMethodClass.
|
|
65
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_find_by_client_guid_and_derp_and_user_guid)
|
|
59
66
|
end
|
|
60
67
|
|
|
61
68
|
it "creates 'cached_exist_search_by_client_guid_and_derp_and_user_guid'" do
|
|
62
|
-
ExistMethodClass.
|
|
69
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_search_by_client_guid_and_derp_and_user_guid)
|
|
63
70
|
end
|
|
64
71
|
|
|
65
72
|
it "creates 'cached_exist_find_by_client_guid_and_user_guid_and_derp'" do
|
|
66
|
-
ExistMethodClass.
|
|
73
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_find_by_client_guid_and_user_guid_and_derp)
|
|
67
74
|
end
|
|
68
75
|
|
|
69
76
|
it "creates 'cached_exist_search_by_client_guid_and_user_guid_and_derp'" do
|
|
70
|
-
ExistMethodClass.
|
|
77
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_search_by_client_guid_and_user_guid_and_derp)
|
|
71
78
|
end
|
|
72
79
|
|
|
73
80
|
# ? based methods
|
|
74
81
|
it "creates 'cached_exist_find_by_guid?'" do
|
|
75
|
-
ExistMethodClass.
|
|
82
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_find_by_guid?)
|
|
76
83
|
end
|
|
77
84
|
|
|
78
85
|
it "creates 'cached_exist_search_by_guid?'" do
|
|
79
|
-
ExistMethodClass.
|
|
86
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_search_by_guid?)
|
|
80
87
|
end
|
|
81
88
|
|
|
82
89
|
it "creates 'cached_exist_find_by_user_guid?'" do
|
|
83
|
-
ExistMethodClass.
|
|
90
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_find_by_user_guid?)
|
|
84
91
|
end
|
|
85
92
|
|
|
86
93
|
it "creates 'cached_exist_search_by_user_guid?'" do
|
|
87
|
-
ExistMethodClass.
|
|
94
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_search_by_user_guid?)
|
|
88
95
|
end
|
|
89
96
|
|
|
90
97
|
it "creates 'cached_exist_find_by_user_guid_and_client_guid?'" do
|
|
91
|
-
ExistMethodClass.
|
|
98
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_find_by_user_guid_and_client_guid?)
|
|
92
99
|
end
|
|
93
100
|
|
|
94
101
|
it "creates 'cached_exist_search_by_user_guid_and_client_guid?'" do
|
|
95
|
-
ExistMethodClass.
|
|
102
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_search_by_user_guid_and_client_guid?)
|
|
96
103
|
end
|
|
97
104
|
|
|
98
105
|
it "creates 'cached_exist_find_by_client_guid_and_user_guid?'" do
|
|
99
|
-
ExistMethodClass.
|
|
106
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_find_by_client_guid_and_user_guid?)
|
|
100
107
|
end
|
|
101
108
|
|
|
102
109
|
it "creates 'cached_exist_search_by_client_guid_and_user_guid?'" do
|
|
103
|
-
ExistMethodClass.
|
|
110
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_search_by_client_guid_and_user_guid?)
|
|
104
111
|
end
|
|
105
112
|
|
|
106
113
|
it "creates 'cached_exist_find_by_derp_and_user_guid_and_client_guid?'" do
|
|
107
|
-
ExistMethodClass.
|
|
114
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_find_by_derp_and_user_guid_and_client_guid?)
|
|
108
115
|
end
|
|
109
116
|
|
|
110
117
|
it "creates 'cached_exist_search_by_derp_and_user_guid_and_client_guid?'" do
|
|
111
|
-
ExistMethodClass.
|
|
118
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_search_by_derp_and_user_guid_and_client_guid?)
|
|
112
119
|
end
|
|
113
120
|
|
|
114
121
|
it "creates 'cached_exist_find_by_client_guid_and_derp_and_user_guid?'" do
|
|
115
|
-
ExistMethodClass.
|
|
122
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_find_by_client_guid_and_derp_and_user_guid?)
|
|
116
123
|
end
|
|
117
124
|
|
|
118
125
|
it "creates 'cached_exist_search_by_client_guid_and_derp_and_user_guid?'" do
|
|
119
|
-
ExistMethodClass.
|
|
126
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_search_by_client_guid_and_derp_and_user_guid?)
|
|
120
127
|
end
|
|
121
128
|
|
|
122
129
|
it "creates 'cached_exist_find_by_client_guid_and_user_guid_and_derp?'" do
|
|
123
|
-
ExistMethodClass.
|
|
130
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_find_by_client_guid_and_user_guid_and_derp?)
|
|
124
131
|
end
|
|
125
132
|
|
|
126
133
|
it "creates 'cached_exist_search_by_client_guid_and_user_guid_and_derp?'" do
|
|
127
|
-
ExistMethodClass.
|
|
134
|
+
expect(ExistMethodClass).to respond_to(:cached_exist_search_by_client_guid_and_user_guid_and_derp?)
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
describe '#cached_exist_find_by_guid?' do
|
|
139
|
+
before do
|
|
140
|
+
::ActiveRemote::Cached.cache(HashCache.new)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
after do
|
|
144
|
+
::ActiveRemote::Cached.default_options({})
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it 'returns false before the find cache key is written' do
|
|
148
|
+
expect(ExistMethodClass.cached_exist_find_by_guid?(:guid)).to eq(false)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it 'returns true after the find cache key is written' do
|
|
152
|
+
ExistMethodClass.cached_find_by_guid(:guid)
|
|
153
|
+
|
|
154
|
+
expect(ExistMethodClass.cached_exist_find_by_guid?(:guid)).to eq(true)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
it 'returns the same result as the method without the question mark' do
|
|
158
|
+
ExistMethodClass.cached_find_by_guid(:guid)
|
|
159
|
+
|
|
160
|
+
expect(ExistMethodClass.cached_exist_find_by_guid(:guid)).to eq(
|
|
161
|
+
ExistMethodClass.cached_exist_find_by_guid?(:guid)
|
|
162
|
+
)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
it 'ignores a search cache key for the same arguments' do
|
|
166
|
+
ExistMethodClass.cached_search_by_guid(:guid)
|
|
167
|
+
|
|
168
|
+
expect(ExistMethodClass.cached_exist_find_by_guid?(:guid)).to eq(false)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
describe 'namespaced cache' do
|
|
172
|
+
it 'uses the namespace as a prefix to the cache key' do
|
|
173
|
+
expect(::ActiveRemote::Cached.cache).to receive(:exist?).with(
|
|
174
|
+
[::ActiveRemote::Cached::RUBY_AND_ACTIVE_SUPPORT_VERSION, 'MyApp', ExistMethodClass.name, '#find',
|
|
175
|
+
'guid.guid']
|
|
176
|
+
).and_return(true)
|
|
177
|
+
|
|
178
|
+
expect(ExistMethodClass.cached_exist_find_by_guid?(:guid, :namespace => 'MyApp')).to eq(true)
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
describe '#cached_exist_search_by_guid?' do
|
|
184
|
+
before do
|
|
185
|
+
::ActiveRemote::Cached.cache(HashCache.new)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
after do
|
|
189
|
+
::ActiveRemote::Cached.default_options({})
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
it 'returns false before the search cache key is written' do
|
|
193
|
+
expect(ExistMethodClass.cached_exist_search_by_guid?(:guid)).to eq(false)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it 'returns true after the search cache key is written' do
|
|
197
|
+
ExistMethodClass.cached_search_by_guid(:guid)
|
|
198
|
+
|
|
199
|
+
expect(ExistMethodClass.cached_exist_search_by_guid?(:guid)).to eq(true)
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it 'ignores a find cache key for the same arguments' do
|
|
203
|
+
ExistMethodClass.cached_find_by_guid(:guid)
|
|
204
|
+
|
|
205
|
+
expect(ExistMethodClass.cached_exist_search_by_guid?(:guid)).to eq(false)
|
|
128
206
|
end
|
|
129
207
|
end
|
|
130
208
|
end
|
|
@@ -1,54 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
class FindMethodClass
|
|
4
6
|
include ::ActiveRemote::Cached
|
|
5
7
|
|
|
6
|
-
def self.find
|
|
7
|
-
|
|
8
|
+
def self.find
|
|
9
|
+
nil
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.search
|
|
13
|
+
nil
|
|
14
|
+
end
|
|
8
15
|
|
|
9
16
|
cached_finders_for :foo, :expires_in => 500
|
|
10
17
|
cached_finders_for :guid
|
|
11
18
|
cached_finders_for :guid, :user_guid
|
|
12
|
-
cached_finders_for [
|
|
13
|
-
cached_finders_for [
|
|
19
|
+
cached_finders_for %i[user_guid client_guid]
|
|
20
|
+
cached_finders_for %i[derp user_guid client_guid]
|
|
14
21
|
end
|
|
15
22
|
|
|
16
23
|
describe FindMethodClass do
|
|
17
|
-
|
|
24
|
+
let(:versioned_prefix) { ::ActiveRemote::Cached::RUBY_AND_ACTIVE_SUPPORT_VERSION }
|
|
25
|
+
|
|
26
|
+
describe 'API' do
|
|
18
27
|
it "creates 'cached_find_by_foo'" do
|
|
19
|
-
FindMethodClass.
|
|
28
|
+
expect(FindMethodClass).to respond_to(:cached_find_by_foo)
|
|
20
29
|
end
|
|
21
30
|
|
|
22
31
|
it "creates 'cached_find_by_guid'" do
|
|
23
|
-
FindMethodClass.
|
|
32
|
+
expect(FindMethodClass).to respond_to(:cached_find_by_guid)
|
|
24
33
|
end
|
|
25
34
|
|
|
26
35
|
it "creates 'cached_find_by_user_guid'" do
|
|
27
|
-
FindMethodClass.
|
|
36
|
+
expect(FindMethodClass).to respond_to(:cached_find_by_user_guid)
|
|
28
37
|
end
|
|
29
38
|
|
|
30
39
|
it "creates 'cached_find_by_user_guid_and_client_guid'" do
|
|
31
|
-
FindMethodClass.
|
|
40
|
+
expect(FindMethodClass).to respond_to(:cached_find_by_user_guid_and_client_guid)
|
|
32
41
|
end
|
|
33
42
|
|
|
34
43
|
it "creates 'cached_find_by_client_guid_and_user_guid'" do
|
|
35
|
-
FindMethodClass.
|
|
44
|
+
expect(FindMethodClass).to respond_to(:cached_find_by_client_guid_and_user_guid)
|
|
36
45
|
end
|
|
37
46
|
|
|
38
47
|
it "creates 'cached_find_by_derp_and_user_guid_and_client_guid'" do
|
|
39
|
-
FindMethodClass.
|
|
48
|
+
expect(FindMethodClass).to respond_to(:cached_find_by_derp_and_user_guid_and_client_guid)
|
|
40
49
|
end
|
|
41
50
|
|
|
42
51
|
it "creates 'cached_find_by_client_guid_and_derp_and_user_guid'" do
|
|
43
|
-
FindMethodClass.
|
|
52
|
+
expect(FindMethodClass).to respond_to(:cached_find_by_client_guid_and_derp_and_user_guid)
|
|
44
53
|
end
|
|
45
54
|
|
|
46
55
|
it "creates 'cached_find_by_client_guid_and_user_guid_and_derp'" do
|
|
47
|
-
FindMethodClass.
|
|
56
|
+
expect(FindMethodClass).to respond_to(:cached_find_by_client_guid_and_user_guid_and_derp)
|
|
48
57
|
end
|
|
49
58
|
end
|
|
50
59
|
|
|
51
|
-
describe
|
|
60
|
+
describe '#cached_find_by_guid' do
|
|
52
61
|
before do
|
|
53
62
|
::ActiveRemote::Cached.cache(HashCache.new)
|
|
54
63
|
::ActiveRemote::Cached.default_options(:expires_in => 100)
|
|
@@ -58,50 +67,50 @@ describe FindMethodClass do
|
|
|
58
67
|
::ActiveRemote::Cached.default_options({})
|
|
59
68
|
end
|
|
60
69
|
|
|
61
|
-
it
|
|
62
|
-
FindMethodClass.
|
|
63
|
-
|
|
64
|
-
end
|
|
70
|
+
it 'executes find_by_guid when cached_find with guid called' do
|
|
71
|
+
expect(FindMethodClass).to receive(:find).and_return(:hello)
|
|
72
|
+
expect(FindMethodClass.cached_find(:guid => :guid)).to eq(:hello)
|
|
65
73
|
end
|
|
66
74
|
|
|
67
|
-
it
|
|
68
|
-
FindMethodClass.
|
|
69
|
-
|
|
70
|
-
end
|
|
75
|
+
it 'executes the fetch block if not present in cache' do
|
|
76
|
+
expect(FindMethodClass).to receive(:find).and_return(:hello)
|
|
77
|
+
expect(FindMethodClass.cached_find_by_guid(:guid)).to eq(:hello)
|
|
71
78
|
end
|
|
72
79
|
|
|
73
|
-
it
|
|
74
|
-
::ActiveRemote::Cached.cache.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
it 'merges the default options in for the fetch call' do
|
|
81
|
+
expect(::ActiveRemote::Cached.cache).to receive(:fetch).with(
|
|
82
|
+
[versioned_prefix, FindMethodClass.name, '#find', 'guid.guid'], { :expires_in => 100 }
|
|
83
|
+
).and_return(:hello)
|
|
84
|
+
expect(FindMethodClass).not_to receive(:find)
|
|
85
|
+
expect(FindMethodClass.cached_find_by_guid(:guid)).to eq(:hello)
|
|
79
86
|
end
|
|
80
87
|
|
|
81
|
-
it
|
|
82
|
-
::ActiveRemote::Cached.cache.
|
|
88
|
+
it 'overrides the default options with local options for the fetch call' do
|
|
89
|
+
expect(::ActiveRemote::Cached.cache).to receive(:fetch).with(
|
|
90
|
+
[versioned_prefix, FindMethodClass.name, '#find', 'guid.guid'], { :expires_in => 200 }
|
|
91
|
+
).and_return(:hello)
|
|
92
|
+
expect(FindMethodClass).not_to receive(:find)
|
|
83
93
|
|
|
84
|
-
FindMethodClass.
|
|
85
|
-
FindMethodClass.cached_find_by_guid(:guid, :expires_in => 200).must_equal(:hello)
|
|
86
|
-
end
|
|
94
|
+
expect(FindMethodClass.cached_find_by_guid(:guid, :expires_in => 200)).to eq(:hello)
|
|
87
95
|
end
|
|
88
96
|
|
|
89
|
-
describe
|
|
97
|
+
describe 'namespaced cache' do
|
|
90
98
|
before do
|
|
91
|
-
::ActiveRemote::Cached.default_options(:expires_in => 100, :namespace =>
|
|
99
|
+
::ActiveRemote::Cached.default_options(:expires_in => 100, :namespace => 'MyApp')
|
|
92
100
|
end
|
|
93
101
|
|
|
94
|
-
it
|
|
95
|
-
::ActiveRemote::Cached.cache.
|
|
102
|
+
it 'uses the namespace as a prefix to the cache key' do
|
|
103
|
+
expect(::ActiveRemote::Cached.cache).to receive(:fetch).with(
|
|
104
|
+
[versioned_prefix, 'MyApp', FindMethodClass.name, '#find', 'guid.guid'], { :expires_in => 100 }
|
|
105
|
+
).and_return(:hello)
|
|
96
106
|
|
|
97
|
-
FindMethodClass.
|
|
98
|
-
|
|
99
|
-
end
|
|
107
|
+
expect(FindMethodClass).not_to receive(:find)
|
|
108
|
+
FindMethodClass.cached_find_by_guid(:guid)
|
|
100
109
|
end
|
|
101
110
|
end
|
|
102
111
|
end
|
|
103
112
|
|
|
104
|
-
describe
|
|
113
|
+
describe '#cached_find_by_foo' do
|
|
105
114
|
before do
|
|
106
115
|
::ActiveRemote::Cached.cache(HashCache.new)
|
|
107
116
|
::ActiveRemote::Cached.default_options(:expires_in => 100)
|
|
@@ -111,20 +120,22 @@ describe FindMethodClass do
|
|
|
111
120
|
::ActiveRemote::Cached.default_options({})
|
|
112
121
|
end
|
|
113
122
|
|
|
114
|
-
it
|
|
115
|
-
::ActiveRemote::Cached.cache.
|
|
123
|
+
it 'overrides the default options with cached_finder options for the fetch call' do
|
|
124
|
+
expect(::ActiveRemote::Cached.cache).to receive(:fetch).with(
|
|
125
|
+
[versioned_prefix, FindMethodClass.name, '#find', 'foo.foo'], { :expires_in => 500 }
|
|
126
|
+
).and_return(:hello)
|
|
116
127
|
|
|
117
|
-
FindMethodClass.
|
|
118
|
-
|
|
119
|
-
end
|
|
128
|
+
expect(FindMethodClass).not_to receive(:find)
|
|
129
|
+
expect(FindMethodClass.cached_find_by_foo(:foo)).to eq(:hello)
|
|
120
130
|
end
|
|
121
131
|
|
|
122
|
-
it
|
|
123
|
-
::ActiveRemote::Cached.cache.
|
|
132
|
+
it 'overrides the cached_finder options with local options for the fetch call' do
|
|
133
|
+
expect(::ActiveRemote::Cached.cache).to receive(:fetch).with(
|
|
134
|
+
[versioned_prefix, FindMethodClass.name, '#find', 'foo.foo'], { :expires_in => 200 }
|
|
135
|
+
).and_return(:hello)
|
|
124
136
|
|
|
125
|
-
FindMethodClass.
|
|
126
|
-
|
|
127
|
-
end
|
|
137
|
+
expect(FindMethodClass).not_to receive(:find)
|
|
138
|
+
expect(FindMethodClass.cached_find_by_foo(:foo, :expires_in => 200)).to eq(:hello)
|
|
128
139
|
end
|
|
129
140
|
end
|
|
130
141
|
end
|