sunspot_submodel_index 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -45,7 +45,7 @@ Examples
45
45
 
46
46
  === If Option
47
47
 
48
- There is also the option to call a Proc before parent is indexed. The Proc is passed the instance of the object. If the Proc returns false the parent is not indexed.
48
+ There is also the option to call a Proc before parent is indexed. The Proc is passed the instance of the object. If the Proc returns false the parent is not indexed. Note, that since the Proc is called on destroy of the object you should write to code to ensure it will not throw and exception in that case.
49
49
 
50
50
  Example
51
51
 
@@ -97,6 +97,7 @@ module Sunspot
97
97
 
98
98
  #always call reindex on destroy
99
99
  def parent_solr_index_on_destroy
100
+ return unless check_parent_solr_if_statement
100
101
  call_parent_solr_index
101
102
  end
102
103
 
@@ -1,3 +1,3 @@
1
1
  module SunspotSubmodelIndex
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -2,6 +2,7 @@ require File.expand_path('../spec_helper', __FILE__)
2
2
 
3
3
  def stub_object_no_index(new_record = false)
4
4
  obj = SunspotSubmodelTestModel.new
5
+ obj.class._sunspot_submodel_options[:if] = nil
5
6
  obj.class._sunspot_submodel_options[:included_attributes] = false
6
7
  obj.class._sunspot_submodel_options[:ignored_attributes] = false
7
8
  obj.stubs(:new_record?).returns(new_record)
@@ -28,6 +29,7 @@ end
28
29
 
29
30
  def stub_object_will_index(new_record = false)
30
31
  obj = SunspotSubmodelTestModel.new
32
+ obj.class._sunspot_submodel_options[:if] = nil
31
33
  obj.class._sunspot_submodel_options[:included_attributes] = false
32
34
  obj.class._sunspot_submodel_options[:ignored_attributes] = false
33
35
  obj.stubs(:new_record?).returns(new_record)
@@ -151,9 +153,18 @@ describe Sunspot::SubmodelIndex do
151
153
  obj = stub_object_will_index
152
154
  obj.destroy
153
155
  end
156
+ it "should not call parents index if the if proc fails" do
157
+ obj = stub_object_no_index
158
+ obj.expects(:check_parent_solr_if_statement).returns false
159
+ obj.destroy
160
+ end
161
+ it "should call parents index if the if proc is ok" do
162
+ obj = stub_object_will_index
163
+ obj.expects(:check_parent_solr_if_statement).returns true
164
+ obj.destroy
165
+ end
154
166
  end
155
167
 
156
-
157
168
  context "force association reload" do
158
169
  it "should call parent with true with option is set" do
159
170
  obj = SunspotSubmodelTestModel.new
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunspot_submodel_index
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Scott Diedrick
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-16 00:00:00 -05:00
18
+ date: 2011-09-19 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency