CloudSesame 0.7.8 → 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -104,9 +104,13 @@ module CloudSesame
104
104
  end
105
105
 
106
106
  def method_missing(name, *args, &block)
107
- builder.respond_to?(name) ? builder.send(name, *args, &block) :
108
- searchable.respond_to?(name) ? searchable.send(name, *args, &block) :
109
- super
107
+ if builder.respond_to?(name, true) || filter_query_scopes[name]
108
+ builder.send(name, *args, &block)
109
+ elsif searchable.respond_to?(name, true)
110
+ searchable.send(name, *args, &block)
111
+ else
112
+ super
113
+ end
110
114
  end
111
115
 
112
116
  # CONTEXT INITIALIZERS
@@ -5,7 +5,7 @@ module CloudSesame
5
5
 
6
6
  def query(input = false)
7
7
  if input || input.nil?
8
- request.query.query = input if input
8
+ request.query.query = input
9
9
  return self
10
10
  else
11
11
  request.query.query
@@ -268,11 +268,11 @@ module CloudSesame
268
268
  context 'when method missing' do
269
269
  let(:undefined_method) { :undefined_method }
270
270
  let(:args) { [1,2,3] }
271
- context 'and builder resposnds to the method' do
272
- let(:builder) { subject.builder }
271
+ let(:builder) { subject.builder }
273
272
  before { allow(subject).to receive(:builder).and_return(builder) }
273
+ context 'and builder resposnds to the method' do
274
274
  it 'should check if builder responds to the method' do
275
- expect(builder).to receive(:respond_to?).with(undefined_method)
275
+ expect(builder).to receive(:respond_to?).with(undefined_method, true)
276
276
  subject.undefined_method rescue nil
277
277
  end
278
278
  it 'should call method on builder with parameters passed in' do
@@ -281,10 +281,20 @@ module CloudSesame
281
281
  subject.undefined_method(*args)
282
282
  end
283
283
  end
284
-
284
+ context 'and scopes responds to the method' do
285
+ let(:filter_query) { { scopes: { undefined_method: nil } } }
286
+ before {
287
+ subject.context[:filter_query] = filter_query
288
+ allow(builder).to receive(undefined_method).and_return(nil)
289
+ }
290
+ it 'should call method on builder with parameters' do
291
+ expect(builder).to receive(undefined_method).with(*args)
292
+ subject.undefined_method(*args)
293
+ end
294
+ end
285
295
  context 'and builder not responds to the methods but searchable do' do
286
296
  it 'should check if callee existing and responds to the method' do
287
- expect(searchable).to receive(:respond_to?).with(undefined_method)
297
+ expect(searchable).to receive(:respond_to?).with(undefined_method, true)
288
298
  subject.undefined_method rescue nil
289
299
  end
290
300
  it 'should call method on searchable with parameters passed in' do
@@ -72,6 +72,8 @@
72
72
  # field :category_string, facet: { sort: 'bucket', size: 10_000 }
73
73
  # field :created_at, type: :datetime
74
74
 
75
+ # scope :min_price, ->(min) { price{ gte(min) } if min }
76
+
75
77
  # end
76
78
 
77
79
  # end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CloudSesame
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.8
4
+ version: 0.7.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chu