elastic_searchable 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -26,7 +26,7 @@ module ElasticSearchable
|
|
26
26
|
# use the "percolations" instance method from within callback to inspect what percolations were returned
|
27
27
|
def elastic_searchable(options = {})
|
28
28
|
cattr_accessor :elastic_options
|
29
|
-
self.elastic_options = options.symbolize_keys
|
29
|
+
self.elastic_options = options.symbolize_keys.merge(:unless => Array.wrap(options[:unless]).push(:elasticsearch_offline?))
|
30
30
|
|
31
31
|
extend ElasticSearchable::Indexing::ClassMethods
|
32
32
|
extend ElasticSearchable::Queries
|
@@ -41,8 +41,8 @@ module ElasticSearchable
|
|
41
41
|
|
42
42
|
attr_accessor :index_lifecycle, :percolations
|
43
43
|
define_model_callbacks :index, :percolate, :only => :after
|
44
|
-
after_commit :update_index_on_create_backgrounded, :if => :should_index?, :
|
45
|
-
after_commit :update_index_on_update_backgrounded, :if => :should_index?, :
|
44
|
+
after_commit :update_index_on_create_backgrounded, :if => :should_index?, :on => :create
|
45
|
+
after_commit :update_index_on_update_backgrounded, :if => :should_index?, :on => :update
|
46
46
|
after_commit :delete_from_index, :unless => :elasticsearch_offline?, :on => :destroy
|
47
47
|
|
48
48
|
class_eval do
|
@@ -104,9 +104,10 @@ class TestElasticSearchable < Test::Unit::TestCase
|
|
104
104
|
|
105
105
|
context 'Model.update' do
|
106
106
|
setup do
|
107
|
-
Post.create
|
107
|
+
Post.create :title => 'foo', :body => 'bar'
|
108
108
|
@post = Post.last
|
109
|
-
@post.
|
109
|
+
@post.title = 'baz'
|
110
|
+
@post.save
|
110
111
|
end
|
111
112
|
should 'have fired after_index callback' do
|
112
113
|
assert @post.indexed?
|
@@ -121,12 +122,10 @@ class TestElasticSearchable < Test::Unit::TestCase
|
|
121
122
|
|
122
123
|
context 'Model.create within ElasticSearchable.offline block' do
|
123
124
|
setup do
|
124
|
-
Post.any_instance.expects(:update_index_on_create).never
|
125
125
|
ElasticSearchable.offline do
|
126
126
|
@post = Post.create :title => 'foo', :body => "bar"
|
127
127
|
end
|
128
128
|
end
|
129
|
-
should 'not have triggered indexing behavior' do end #see expectations
|
130
129
|
should 'not have fired after_index callback' do
|
131
130
|
assert !@post.indexed?
|
132
131
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic_searchable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 3
|
10
|
+
version: 1.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Sonnek
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04
|
18
|
+
date: 2011-05-04 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activerecord
|