active_remote-cached 0.2.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +55 -0
- data/Gemfile +2 -0
- data/Rakefile +6 -4
- data/active_remote-cached.gemspec +23 -17
- data/lib/active_remote/cached/argument_keys.rb +49 -46
- data/lib/active_remote/cached/cache.rb +50 -49
- data/lib/active_remote/cached/railtie.rb +5 -5
- data/lib/active_remote/cached/version.rb +3 -1
- data/lib/active_remote/cached.rb +149 -84
- data/lib/active_remote-cached.rb +3 -1
- data/spec/active_remote/cached/argument_keys_spec.rb +12 -10
- data/spec/active_remote/cached/cache_spec.rb +13 -16
- data/spec/active_remote/cached_delete_methods_spec.rb +19 -12
- data/spec/active_remote/cached_exist_methods_spec.rb +40 -33
- data/spec/active_remote/cached_find_methods_spec.rb +64 -51
- data/spec/active_remote/cached_search_methods_spec.rb +153 -102
- data/spec/spec_helper.rb +5 -10
- metadata +41 -10
data/lib/active_remote/cached.rb
CHANGED
@@ -1,38 +1,41 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/cache'
|
3
|
+
require 'active_support/concern'
|
4
|
+
require 'active_support/core_ext/array/extract_options'
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
6
|
+
require 'active_remote/cached/argument_keys'
|
7
|
+
require 'active_remote/cached/cache'
|
8
|
+
require 'active_remote/cached/version'
|
9
|
+
require 'active_remote/errors'
|
10
10
|
|
11
11
|
module ActiveRemote
|
12
12
|
module Cached
|
13
13
|
extend ::ActiveSupport::Concern
|
14
14
|
|
15
|
-
# When upgrading Rails versions, don't reuse the same cache key,
|
16
|
-
#
|
15
|
+
# When upgrading Rails versions, don't reuse the same cache key,
|
16
|
+
# because you can't rely upon the serialized objects to be consistent across versions.
|
17
|
+
# To fix, this adds a cache key that caches the ruby engine version
|
18
|
+
# and the activesupport version to prevent cache re-use across different versions.
|
17
19
|
RUBY_AND_ACTIVE_SUPPORT_VERSION = "#{RUBY_ENGINE_VERSION}:#{ActiveSupport::VERSION::STRING}".freeze
|
18
20
|
|
19
21
|
def self.cache(cache_provider = nil)
|
20
|
-
if cache_provider
|
21
|
-
@cache_provider = ::ActiveRemote::Cached::Cache.new(cache_provider)
|
22
|
-
end
|
22
|
+
@cache_provider = ::ActiveRemote::Cached::Cache.new(cache_provider) if cache_provider
|
23
23
|
|
24
24
|
@cache_provider
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.default_options(options = nil)
|
28
|
-
if options
|
29
|
-
@default_options = options
|
30
|
-
end
|
28
|
+
@default_options = options if options
|
31
29
|
|
32
30
|
@default_options || {}
|
33
31
|
end
|
34
32
|
|
35
33
|
module ClassMethods
|
34
|
+
def cached_methods
|
35
|
+
@cached_methods ||= []
|
36
|
+
@cached_methods
|
37
|
+
end
|
38
|
+
|
36
39
|
def cached_finders_for(*cached_finder_keys)
|
37
40
|
options = cached_finder_keys.extract_options!
|
38
41
|
|
@@ -45,102 +48,157 @@ module ActiveRemote
|
|
45
48
|
cached_finders_for(*keys)
|
46
49
|
end
|
47
50
|
|
48
|
-
def cached_find(argument_hash, options = {})
|
51
|
+
def cached_find(argument_hash, options = {}, &block)
|
49
52
|
method_name = _cached_find_method_name(argument_hash.keys)
|
50
|
-
arguments = argument_hash.
|
53
|
+
arguments = argument_hash.keys.sort.map { |k| argument_hash[k] }
|
51
54
|
|
52
55
|
if block_given?
|
53
|
-
__send__(method_name, *arguments, options)
|
54
|
-
yield
|
55
|
-
end
|
56
|
+
__send__(method_name, *arguments, options, &block)
|
56
57
|
else
|
57
58
|
__send__(method_name, *arguments, options)
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
61
|
-
def cached_search(argument_hash, options = {})
|
62
|
+
def cached_search(argument_hash, options = {}, &block)
|
62
63
|
method_name = _cached_search_method_name(argument_hash.keys)
|
63
|
-
arguments = argument_hash.
|
64
|
+
arguments = argument_hash.keys.sort.map { |k| argument_hash[k] }
|
64
65
|
|
65
66
|
if block_given?
|
66
|
-
__send__(method_name, *arguments, options)
|
67
|
-
yield
|
68
|
-
end
|
67
|
+
__send__(method_name, *arguments, options, &block)
|
69
68
|
else
|
70
69
|
__send__(method_name, *arguments, options)
|
71
70
|
end
|
72
71
|
end
|
73
72
|
|
73
|
+
def method_missing(m, *args, &block)
|
74
|
+
method_name = _method_missing_name(m)
|
75
|
+
|
76
|
+
if method_name.nil? || !cached_methods.include?(method_name.to_s)
|
77
|
+
super(m, *args, &block)
|
78
|
+
else
|
79
|
+
new_args = _args_in_sorted_order(m, args)
|
80
|
+
__send__(method_name, *new_args, &block)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def respond_to_missing?(m, include_private = false)
|
85
|
+
method_name = _method_missing_name(m)
|
86
|
+
|
87
|
+
if !method_name.nil? && cached_methods.include?(method_name.to_s)
|
88
|
+
true
|
89
|
+
else
|
90
|
+
super
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
74
94
|
##
|
75
95
|
# Underscored Methods
|
76
96
|
#
|
77
|
-
def
|
78
|
-
|
79
|
-
|
80
|
-
##
|
81
|
-
# Run each permutation of the arguments passed in
|
82
|
-
# and define each finder/searcher
|
83
|
-
#
|
84
|
-
cached_finder_key_set.permutation do |arguments|
|
85
|
-
delete_method_name = _cached_delete_method_name(arguments)
|
86
|
-
exist_find_method_name = _cached_exist_find_method_name(arguments)
|
87
|
-
exist_search_method_name = _cached_exist_search_method_name(arguments)
|
88
|
-
find_method_name = _cached_find_method_name(arguments)
|
89
|
-
search_method_name = _cached_search_method_name(arguments)
|
90
|
-
search_bang_method_name = "#{search_method_name}!"
|
91
|
-
|
92
|
-
unless self.respond_to?(delete_method_name)
|
93
|
-
_define_cached_delete_method(delete_method_name, arguments, options)
|
94
|
-
end
|
97
|
+
def _method_missing_name(m)
|
98
|
+
regex = /(cached_(?:delete|exist_search|search|exist_find|find)_by_)([0-9a-zA-Z_]*)(!|\?)?/
|
95
99
|
|
96
|
-
|
97
|
-
_define_cached_exist_find_method(exist_find_method_name, arguments, options)
|
98
|
-
end
|
100
|
+
return unless m.to_s =~ regex
|
99
101
|
|
100
|
-
|
101
|
-
|
102
|
-
|
102
|
+
params = ::Regexp.last_match(2).split('_and_')
|
103
|
+
"#{::Regexp.last_match(1)}#{params.sort.join('_and_')}#{::Regexp.last_match(3)}".to_sym
|
104
|
+
end
|
103
105
|
|
104
|
-
|
105
|
-
|
106
|
-
|
106
|
+
# rubocop:disable Metrics/AbcSize
|
107
|
+
def _args_in_sorted_order(m, args)
|
108
|
+
regex = /cached_(?:delete|exist_search|search|exist_find|find)_by_([0-9a-zA-Z_]*)(!|\?)?/
|
107
109
|
|
108
|
-
|
109
|
-
|
110
|
+
method_name = _method_missing_name(m)
|
111
|
+
|
112
|
+
match_1 = m.match(regex)
|
113
|
+
match_2 = method_name.match(regex)
|
114
|
+
|
115
|
+
args_in_order = []
|
116
|
+
|
117
|
+
if match_1[1] && match_2[1]
|
118
|
+
orignal_args_name = match_1[1].split('_and_')
|
119
|
+
args_names_in_order = match_2[1].split('_and_')
|
120
|
+
|
121
|
+
args_names_in_order.each do |arg_name|
|
122
|
+
index = orignal_args_name.index(arg_name)
|
123
|
+
args_in_order << args[index]
|
110
124
|
end
|
111
125
|
|
112
|
-
|
113
|
-
|
126
|
+
if args.size > args_in_order.size
|
127
|
+
# Add options if passed
|
128
|
+
args_in_order << args.last
|
114
129
|
end
|
130
|
+
|
131
|
+
args_in_order
|
132
|
+
else
|
133
|
+
args
|
134
|
+
end
|
135
|
+
end
|
136
|
+
# rubocop:enable Metrics/AbcSize
|
137
|
+
|
138
|
+
# rubocop:disable Metrics/AbcSize
|
139
|
+
def _create_cached_finder_for(cached_finder_key, options = {})
|
140
|
+
cached_finder_key_set = [cached_finder_key].flatten.sort
|
141
|
+
|
142
|
+
delete_method_name = _cached_delete_method_name(cached_finder_key_set)
|
143
|
+
exist_find_method_name = _cached_exist_find_method_name(cached_finder_key_set)
|
144
|
+
exist_search_method_name = _cached_exist_search_method_name(cached_finder_key_set)
|
145
|
+
find_method_name = _cached_find_method_name(cached_finder_key_set)
|
146
|
+
search_method_name = _cached_search_method_name(cached_finder_key_set)
|
147
|
+
search_bang_method_name = "#{search_method_name}!"
|
148
|
+
|
149
|
+
unless cached_methods.include?(delete_method_name)
|
150
|
+
_define_cached_delete_method(delete_method_name, cached_finder_key_set, options)
|
151
|
+
end
|
152
|
+
|
153
|
+
unless cached_methods.include?(exist_find_method_name)
|
154
|
+
_define_cached_exist_find_method(exist_find_method_name, cached_finder_key_set, options)
|
115
155
|
end
|
156
|
+
|
157
|
+
unless cached_methods.include?(exist_search_method_name)
|
158
|
+
_define_cached_exist_search_method(exist_search_method_name, cached_finder_key_set, options)
|
159
|
+
end
|
160
|
+
|
161
|
+
unless cached_methods.include?(find_method_name)
|
162
|
+
_define_cached_find_method(find_method_name, cached_finder_key_set, options)
|
163
|
+
end
|
164
|
+
|
165
|
+
unless cached_methods.include?(search_bang_method_name)
|
166
|
+
_define_cached_search_bang_method(search_bang_method_name, cached_finder_key_set, options)
|
167
|
+
end
|
168
|
+
|
169
|
+
return if cached_methods.include?(search_method_name)
|
170
|
+
|
171
|
+
_define_cached_search_method(search_method_name, cached_finder_key_set, options)
|
116
172
|
end
|
173
|
+
# rubocop:enable Metrics/AbcSize
|
117
174
|
|
118
175
|
def _cached_delete_method_name(arguments)
|
119
|
-
"cached_delete_by_#{arguments.join('_and_')}"
|
176
|
+
"cached_delete_by_#{arguments.sort.join('_and_')}"
|
120
177
|
end
|
121
178
|
|
122
179
|
def _cached_exist_find_method_name(arguments)
|
123
|
-
"cached_exist_find_by_#{arguments.join('_and_')}"
|
180
|
+
"cached_exist_find_by_#{arguments.sort.join('_and_')}"
|
124
181
|
end
|
125
182
|
|
126
183
|
def _cached_exist_search_method_name(arguments)
|
127
|
-
"cached_exist_search_by_#{arguments.join('_and_')}"
|
184
|
+
"cached_exist_search_by_#{arguments.sort.join('_and_')}"
|
128
185
|
end
|
129
186
|
|
130
187
|
def _cached_find_method_name(arguments)
|
131
|
-
"cached_find_by_#{arguments.join('_and_')}"
|
188
|
+
"cached_find_by_#{arguments.sort.join('_and_')}"
|
132
189
|
end
|
133
190
|
|
134
191
|
def _cached_search_method_name(arguments)
|
135
|
-
"cached_search_by_#{arguments.join('_and_')}"
|
192
|
+
"cached_search_by_#{arguments.sort.join('_and_')}"
|
136
193
|
end
|
137
194
|
|
138
195
|
def _define_cached_delete_method(method_name, *method_arguments, cached_finder_options)
|
139
196
|
method_arguments.flatten!
|
140
|
-
expanded_method_args = method_arguments.join(
|
141
|
-
sorted_method_args = method_arguments.sort.join(
|
197
|
+
expanded_method_args = method_arguments.join(',')
|
198
|
+
sorted_method_args = method_arguments.sort.join(',')
|
199
|
+
cached_methods << method_name
|
142
200
|
|
143
|
-
|
201
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
144
202
|
# def self.cached_delete_by_user_guid(user_guid, options = {})
|
145
203
|
# ::ActiveRemote::Cached.cache.delete([name, user_guid])
|
146
204
|
# end
|
@@ -171,10 +229,12 @@ module ActiveRemote
|
|
171
229
|
|
172
230
|
def _define_cached_exist_find_method(method_name, *method_arguments, cached_finder_options)
|
173
231
|
method_arguments.flatten!
|
174
|
-
expanded_method_args = method_arguments.join(
|
175
|
-
sorted_method_args = method_arguments.sort.join(
|
232
|
+
expanded_method_args = method_arguments.join(',')
|
233
|
+
sorted_method_args = method_arguments.sort.join(',')
|
234
|
+
cached_methods << method_name
|
235
|
+
cached_methods << "#{method_name}?"
|
176
236
|
|
177
|
-
|
237
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
178
238
|
# def self.cached_exist_find_by_user_guid(user_guid, options = {})
|
179
239
|
# ::ActiveRemote::Cached.cache.exist?([name, user_guid])
|
180
240
|
# end
|
@@ -198,10 +258,12 @@ module ActiveRemote
|
|
198
258
|
|
199
259
|
def _define_cached_exist_search_method(method_name, *method_arguments, cached_finder_options)
|
200
260
|
method_arguments.flatten!
|
201
|
-
expanded_method_args = method_arguments.join(
|
202
|
-
sorted_method_args = method_arguments.sort.join(
|
261
|
+
expanded_method_args = method_arguments.join(',')
|
262
|
+
sorted_method_args = method_arguments.sort.join(',')
|
263
|
+
cached_methods << method_name
|
264
|
+
cached_methods << "#{method_name}?"
|
203
265
|
|
204
|
-
|
266
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
205
267
|
# def self.cached_exist_search_by_user_guid(user_guid, options = {})
|
206
268
|
# ::ActiveRemote::Cached.cache.exist?([namespace, name, "#search", user_guid])
|
207
269
|
# end
|
@@ -225,15 +287,16 @@ module ActiveRemote
|
|
225
287
|
|
226
288
|
def _define_cached_find_method(method_name, *method_arguments, cached_finder_options)
|
227
289
|
method_arguments.flatten!
|
228
|
-
expanded_method_args = method_arguments.join(
|
229
|
-
sorted_method_args = method_arguments.sort.join(
|
290
|
+
expanded_method_args = method_arguments.join(',')
|
291
|
+
sorted_method_args = method_arguments.sort.join(',')
|
292
|
+
cached_methods << method_name
|
230
293
|
|
231
|
-
expanded_search_args =
|
294
|
+
expanded_search_args = ''
|
232
295
|
method_arguments.each do |method_argument|
|
233
296
|
expanded_search_args << ":#{method_argument} => #{method_argument},"
|
234
297
|
end
|
235
298
|
|
236
|
-
|
299
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
237
300
|
# def self.cached_find_by_user_guid(user_guid, options = {})
|
238
301
|
# options = ::ActiveRemote::Cached.default_options.merge({}).merge(options)
|
239
302
|
#
|
@@ -269,15 +332,16 @@ module ActiveRemote
|
|
269
332
|
|
270
333
|
def _define_cached_search_method(method_name, *method_arguments, cached_finder_options)
|
271
334
|
method_arguments.flatten!
|
272
|
-
expanded_method_args = method_arguments.join(
|
273
|
-
sorted_method_args = method_arguments.sort.join(
|
335
|
+
expanded_method_args = method_arguments.join(',')
|
336
|
+
sorted_method_args = method_arguments.sort.join(',')
|
337
|
+
cached_methods << method_name
|
274
338
|
|
275
|
-
expanded_search_args =
|
339
|
+
expanded_search_args = ''
|
276
340
|
method_arguments.each do |method_argument|
|
277
341
|
expanded_search_args << ":#{method_argument} => #{method_argument},"
|
278
342
|
end
|
279
343
|
|
280
|
-
|
344
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
281
345
|
# def self.cached_search_by_user_guid(user_guid, options = {})
|
282
346
|
# options = ::ActiveRemote::Cached.default_options.merge({}).merge(options)
|
283
347
|
#
|
@@ -317,15 +381,16 @@ module ActiveRemote
|
|
317
381
|
|
318
382
|
def _define_cached_search_bang_method(method_name, *method_arguments, cached_finder_options)
|
319
383
|
method_arguments.flatten!
|
320
|
-
expanded_method_args = method_arguments.join(
|
321
|
-
sorted_method_args = method_arguments.sort.join(
|
384
|
+
expanded_method_args = method_arguments.join(',')
|
385
|
+
sorted_method_args = method_arguments.sort.join(',')
|
386
|
+
cached_methods << method_name
|
322
387
|
|
323
|
-
expanded_search_args =
|
388
|
+
expanded_search_args = ''
|
324
389
|
method_arguments.each do |method_argument|
|
325
390
|
expanded_search_args << ":#{method_argument} => #{method_argument},"
|
326
391
|
end
|
327
392
|
|
328
|
-
|
393
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
329
394
|
# def self.cached_search_by_user_guid!(user_guid, options = {})
|
330
395
|
# options = ::ActiveRemote::Cached.default_options.merge({}).merge(options)
|
331
396
|
#
|
@@ -379,4 +444,4 @@ module ActiveRemote
|
|
379
444
|
end
|
380
445
|
end
|
381
446
|
|
382
|
-
require
|
447
|
+
require 'active_remote/cached/railtie' if defined?(Rails)
|
data/lib/active_remote-cached.rb
CHANGED
@@ -1,25 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe ::ActiveRemote::Cached::ArgumentKeys do
|
4
|
-
it
|
5
|
-
::ActiveRemote::Cached::ArgumentKeys.new(
|
6
|
+
it 'does not mutate a string by default' do
|
7
|
+
expect(::ActiveRemote::Cached::ArgumentKeys.new('hello', {}).cache_key).to eq('hello')
|
6
8
|
end
|
7
9
|
|
8
|
-
it
|
9
|
-
::ActiveRemote::Cached::ArgumentKeys.new(:hello, {}).cache_key.
|
10
|
+
it 'returns a string of a symbol by default' do
|
11
|
+
expect(::ActiveRemote::Cached::ArgumentKeys.new(:hello, {}).cache_key).to eq('hello')
|
10
12
|
end
|
11
13
|
|
12
|
-
it
|
13
|
-
::ActiveRemote::Cached::ArgumentKeys.new(
|
14
|
+
it 'does not mutate a string with special characters by default' do
|
15
|
+
expect(::ActiveRemote::Cached::ArgumentKeys.new('hello {}', {}).cache_key).to eq('hello {}')
|
14
16
|
end
|
15
17
|
|
16
|
-
it
|
18
|
+
it 'removes special characters from string with special characters when :active_remote_cached_remove_characters' do
|
17
19
|
options = { :active_remote_cached_remove_characters => true }
|
18
|
-
::ActiveRemote::Cached::ArgumentKeys.new(
|
20
|
+
expect(::ActiveRemote::Cached::ArgumentKeys.new('hello {}', options).cache_key).to eq('hello')
|
19
21
|
end
|
20
22
|
|
21
|
-
it
|
23
|
+
it 'replaces special characters from string with special characters when :active_remote_cached_replace_characters' do
|
22
24
|
options = { :active_remote_cached_replace_characters => true }
|
23
|
-
::ActiveRemote::Cached::ArgumentKeys.new(
|
25
|
+
expect(::ActiveRemote::Cached::ArgumentKeys.new('hello {}', options).cache_key).to eq('helloSPLBRB')
|
24
26
|
end
|
25
27
|
end
|
@@ -1,35 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe ::ActiveRemote::Cached::Cache do
|
4
|
-
describe
|
5
|
-
it
|
6
|
+
describe 'API' do
|
7
|
+
it 'validates #delete present' do
|
6
8
|
cache = OpenStruct.new(:write => nil, :fetch => nil, :read => nil, :exist? => nil)
|
7
|
-
|
8
|
-
error.message.must_match(/respond_to.*delete/i)
|
9
|
+
expect { ::ActiveRemote::Cached.cache(cache) }.to raise_error(RuntimeError, /respond_to.*delete/i)
|
9
10
|
end
|
10
11
|
|
11
|
-
it
|
12
|
+
it 'validates #exist? present' do
|
12
13
|
cache = OpenStruct.new(:write => nil, :delete => nil, :read => nil, :fetch => nil)
|
13
|
-
|
14
|
-
error.message.must_match(/respond_to.*exist/i)
|
14
|
+
expect { ::ActiveRemote::Cached.cache(cache) }.to raise_error(RuntimeError, /respond_to.*exist/i)
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it 'validates #fetch present' do
|
18
18
|
cache = OpenStruct.new(:write => nil, :delete => nil, :read => nil, :exist? => nil)
|
19
|
-
|
20
|
-
error.message.must_match(/respond_to.*fetch/i)
|
19
|
+
expect { ::ActiveRemote::Cached.cache(cache) }.to raise_error(RuntimeError, /respond_to.*fetch/i)
|
21
20
|
end
|
22
21
|
|
23
|
-
it
|
22
|
+
it 'validates #read present' do
|
24
23
|
cache = OpenStruct.new(:write => nil, :delete => nil, :fetch => nil, :exist? => nil)
|
25
|
-
|
26
|
-
error.message.must_match(/respond_to.*read/i)
|
24
|
+
expect { ::ActiveRemote::Cached.cache(cache) }.to raise_error(RuntimeError, /respond_to.*read/i)
|
27
25
|
end
|
28
26
|
|
29
|
-
it
|
27
|
+
it 'validates #write present' do
|
30
28
|
cache = OpenStruct.new(:read => nil, :delete => nil, :fetch => nil, :exist? => nil)
|
31
|
-
|
32
|
-
error.message.must_match(/respond_to.*write/i)
|
29
|
+
expect { ::ActiveRemote::Cached.cache(cache) }.to raise_error(RuntimeError, /respond_to.*write/i)
|
33
30
|
end
|
34
31
|
end
|
35
32
|
end
|
@@ -1,45 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
class DeleteMethodClass
|
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 :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 DeleteMethodClass do
|
16
|
-
describe
|
23
|
+
describe 'API' do
|
17
24
|
it "creates 'cached_delete_by_guid'" do
|
18
|
-
DeleteMethodClass.
|
25
|
+
expect(DeleteMethodClass).to respond_to(:cached_delete_by_guid)
|
19
26
|
end
|
20
27
|
|
21
28
|
it "creates 'cached_delete_by_user_guid'" do
|
22
|
-
DeleteMethodClass.
|
29
|
+
expect(DeleteMethodClass).to respond_to(:cached_delete_by_user_guid)
|
23
30
|
end
|
24
31
|
|
25
32
|
it "creates 'cached_delete_by_user_guid_and_client_guid'" do
|
26
|
-
DeleteMethodClass.
|
33
|
+
expect(DeleteMethodClass).to respond_to(:cached_delete_by_user_guid_and_client_guid)
|
27
34
|
end
|
28
35
|
|
29
36
|
it "creates 'cached_delete_by_client_guid_and_user_guid'" do
|
30
|
-
DeleteMethodClass.
|
37
|
+
expect(DeleteMethodClass).to respond_to(:cached_delete_by_client_guid_and_user_guid)
|
31
38
|
end
|
32
39
|
|
33
40
|
it "creates 'cached_delete_by_derp_and_user_guid_and_client_guid'" do
|
34
|
-
DeleteMethodClass.
|
41
|
+
expect(DeleteMethodClass).to respond_to(:cached_delete_by_derp_and_user_guid_and_client_guid)
|
35
42
|
end
|
36
43
|
|
37
44
|
it "creates 'cached_delete_by_client_guid_and_derp_and_user_guid'" do
|
38
|
-
DeleteMethodClass.
|
45
|
+
expect(DeleteMethodClass).to respond_to(:cached_delete_by_client_guid_and_derp_and_user_guid)
|
39
46
|
end
|
40
47
|
|
41
48
|
it "creates 'cached_delete_by_client_guid_and_user_guid_and_derp'" do
|
42
|
-
DeleteMethodClass.
|
49
|
+
expect(DeleteMethodClass).to respond_to(:cached_delete_by_client_guid_and_user_guid_and_derp)
|
43
50
|
end
|
44
51
|
end
|
45
52
|
end
|