elasticsearch-persistence 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTQ2NWJlZWJlNDE0ODRhODAzZDM2ZDFhYTFiNDkzNTdlMTZkZjQzYQ==
4
+ YmNiMTYwMzJjY2E2YjYyOTRmZTJkYWRlZGMxZGJiNDIzN2I5ODUxMA==
5
5
  data.tar.gz: !binary |-
6
- MmUzOGJiN2I0MmY1ZDBmOTg3NjRiOWM0NDk2NjkzN2Q0N2I2Yjk3Mg==
6
+ OWE0ZGRhYzM4YTljMzEyZGFlOWM3NDg1OWM2MGE5MTY4Mzk2Y2Q5Yw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTViMmMzZTNlMGVhMTE4ZWIzYzJmYjU1ZGQwMWJlMzVmMWQ4ZmM2Y2YyNTcz
10
- NWQ2NDE2NDlkYzI2YTFkMjMxOWVlMWZlZWE5MWQ4MmNlNjQxMzc1MWVkNzZk
11
- MTcxYjM2OTk1MDNlNDQ5NjNiNzk1NTkxNGVlNjVjNTMyZTI4Mzk=
9
+ ODQ0M2FiZmU2NmUxNjZkODI1NmZhZDU3MDIyZWI1M2IyMjBkOTNmOTlkZDY2
10
+ ZTg1OWRmNmRkMDZhYzc0NWEwNTM5YzA4Nzg2NDhlYTU5ZDczYzcyMDZhYjg3
11
+ MDZkMjc4OTUwNjcwYmZiYjc1ZGEwMmQzNjRkNDY1MGI1OGU5MWQ=
12
12
  data.tar.gz: !binary |-
13
- ZjFmNDc0MWYyOTZjNTcwZmNjMzBmYzY5ZTlmZmFmODM3MzEwNTg0OTAwYmY5
14
- MzZkZTFmZjNmNzliZTFiNTY4YTZhMjVhYWY1MmNmZWRiNTJmZWYwNDNiYWFj
15
- ZmRhMmZhNzg1ZTAyNDI3ODJhODRlMGI3MjI5NDczZTNhYmU4NzQ=
13
+ MGI1NzQ1ZjcwZjZkNWZhMWRmMDA5ZjE3NGQzMDNkMjM3Y2NhMjVmZWY0MjE2
14
+ NDJlZTRiYzgzNmQ1MDJjOGFhZDk4M2M0MzU2M2I1ZTE3ODIyZmIxODUzMTYw
15
+ MWM4MDQ4ZGJhZDc3MjEwMmYzZjEyMzAwZTJiMWY5ZDMxYmJlMGY=
@@ -1,3 +1,8 @@
1
+ ## 0.1.5
2
+
3
+ * Improved documentation
4
+ * Added `@mymodel.id=` setter method
5
+
1
6
  ## 0.1.4
2
7
 
3
8
  * Added the Elasticsearch::Persistence::Model feature
data/README.md CHANGED
@@ -492,7 +492,7 @@ class Article
492
492
  end
493
493
  ```
494
494
 
495
- Attribute validations works like for any other _ActiveModel_-compatible implementation:
495
+ Attribute validations work like for any other _ActiveModel_-compatible implementation:
496
496
 
497
497
  ```ruby
498
498
  article = Article.new # => #<Article { ... }>
@@ -535,7 +535,7 @@ To update the model, either update the attribute and save the model:
535
535
  article.title = 'Updated'
536
536
 
537
537
  article.save
538
- => {"_index"=>"articles", "_type"=>"article", "_id"=>"1", "_version"=>2, "created"=>false}
538
+ # => {"_index"=>"articles", "_type"=>"article", "_id"=>"1", "_version"=>2, "created"=>false}
539
539
  ```
540
540
 
541
541
  ... or use the `update_attributes` method:
@@ -571,7 +571,7 @@ article.save
571
571
  ```
572
572
 
573
573
  The model also supports familiar `find_in_batches` and `find_each` methods to efficiently
574
- retrieve big collections of model instance, using the Elasticsearch's _Scan API_:
574
+ retrieve big collections of model instances, using the Elasticsearch's _Scan API_:
575
575
 
576
576
  ```ruby
577
577
  Article.find_each(_source_include: 'title') { |a| puts "===> #{a.title.upcase}" }
@@ -604,7 +604,7 @@ puts results.response.aggregations.authors.buckets.each { |b| puts "#{b['key']}
604
604
 
605
605
  #### Accessing the Repository Gateway
606
606
 
607
- The Elasticsearch integration is implemented by embedding the repository object in the model.
607
+ The integration with Elasticsearch is implemented by embedding the repository object in the model.
608
608
  You can access it through the `gateway` method:
609
609
 
610
610
  ```ruby
@@ -634,7 +634,7 @@ article.published.iso8601
634
634
  # => "2014-01-01"
635
635
  ```
636
636
 
637
- The library provides a Rails ORM generator:
637
+ The library provides a Rails ORM generator to facilitate building the application scaffolding:
638
638
 
639
639
  ```bash
640
640
  rails generate scaffold Person name:String email:String birthday:Date --orm=elasticsearch
@@ -645,16 +645,16 @@ rails generate scaffold Person name:String email:String birthday:Date --orm=elas
645
645
  A fully working Ruby on Rails application can be generated with the following command:
646
646
 
647
647
  ```bash
648
- rails new music --force --skip --skip-bundle --skip-active-record --template https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/template.rb
648
+ rails new music --force --skip --skip-bundle --skip-active-record --template https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/template.rb
649
649
  ```
650
650
 
651
651
  The application demonstrates:
652
652
 
653
653
  * How to set up model attributes with custom mappings
654
- * How to configure model relationships with Elasticsearch's parent/child
654
+ * How to define model relationships with Elasticsearch's parent/child
655
655
  * How to configure models to use a common index, and create the index with proper mappings
656
656
  * How to use Elasticsearch's completion suggester to drive auto-complete functionality
657
- * How to use Elasticsearch-persisted model in Rails' views and forms
657
+ * How to use Elasticsearch-persisted models in Rails' views and forms
658
658
  * How to write controller tests
659
659
 
660
660
  The source files for the application are available in the [`examples/music`](examples/music) folder.
@@ -39,13 +39,15 @@ Gem::Specification.new do |s|
39
39
 
40
40
  s.add_development_dependency "elasticsearch-extensions"
41
41
 
42
+ s.add_development_dependency "minitest", "~> 4"
43
+ s.add_development_dependency "test-unit" if defined?(RUBY_VERSION) && RUBY_VERSION > '2.2'
42
44
  s.add_development_dependency "shoulda-context"
43
45
  s.add_development_dependency "mocha"
44
46
  s.add_development_dependency "turn"
45
47
  s.add_development_dependency "yard"
46
48
  s.add_development_dependency "ruby-prof"
47
49
  s.add_development_dependency "pry"
48
- s.add_development_dependency "ci_reporter"
50
+ s.add_development_dependency "ci_reporter", "~> 1.9"
49
51
 
50
52
  if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
51
53
  s.add_development_dependency "simplecov"
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # This file creates a fully working Rails application with support for storing and retrieving models
6
6
  # in Elasticsearch, using the `elasticsearch-persistence` gem
7
- # (https://github.com/elasticsearch/elasticsearch-rails/tree/persistence-model/elasticsearch-persistence).
7
+ # (https://github.com/elasticsearch/elasticsearch-rails/tree/master/elasticsearch-persistence).
8
8
  #
9
9
  # Requirements:
10
10
  # -------------
@@ -173,9 +173,9 @@ if ENV['LOCAL']
173
173
  copy_file File.expand_path('../vendor/assets/jquery-ui-1.10.4.custom.min.css', __FILE__),
174
174
  'vendor/assets/stylesheets/ui-lightness/jquery-ui-1.10.4.custom.min.css'
175
175
  else
176
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/vendor/assets/jquery-ui-1.10.4.custom.min.js',
176
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/vendor/assets/jquery-ui-1.10.4.custom.min.js',
177
177
  'vendor/assets/javascripts/jquery-ui-1.10.4.custom.min.js'
178
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/vendor/assets/jquery-ui-1.10.4.custom.min.css',
178
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/vendor/assets/jquery-ui-1.10.4.custom.min.css',
179
179
  'vendor/assets/stylesheets/ui-lightness/jquery-ui-1.10.4.custom.min.css'
180
180
  end
181
181
 
@@ -217,11 +217,11 @@ if ENV['LOCAL']
217
217
  copy_file File.expand_path('../album.rb', __FILE__), 'app/models/album.rb'
218
218
  copy_file File.expand_path('../suggester.rb', __FILE__), 'app/models/suggester.rb'
219
219
  else
220
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/artist.rb',
220
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/artist.rb',
221
221
  'app/models/artist.rb'
222
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/album.rb',
222
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/album.rb',
223
223
  'app/models/album.rb'
224
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/suggester.rb',
224
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/suggester.rb',
225
225
  'app/models/suggester.rb'
226
226
  end
227
227
 
@@ -242,15 +242,15 @@ if ENV['LOCAL']
242
242
  copy_file File.expand_path('../artists/artists_controller_test.rb', __FILE__),
243
243
  'test/controllers/artists_controller_test.rb'
244
244
  else
245
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/artists/artists_controller.rb',
245
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/artists/artists_controller.rb',
246
246
  'app/controllers/artists_controller.rb'
247
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/artists/index.html.erb',
247
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/artists/index.html.erb',
248
248
  'app/views/artists/index.html.erb'
249
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/artists/show.html.erb',
249
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/artists/show.html.erb',
250
250
  'app/views/artists/show.html.erb'
251
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/artists/_form.html.erb',
251
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/artists/_form.html.erb',
252
252
  'app/views/artists/_form.html.erb'
253
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/artists/artists_controller_test.rb',
253
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/artists/artists_controller_test.rb',
254
254
  'test/controllers/artists_controller_test.rb'
255
255
  end
256
256
 
@@ -267,13 +267,13 @@ if ENV['LOCAL']
267
267
  copy_file File.expand_path('../search/search_controller_test.rb', __FILE__),
268
268
  'test/controllers/search_controller_test.rb'
269
269
  else
270
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/search/search_controller.rb',
270
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/search/search_controller.rb',
271
271
  'app/controllers/search_controller.rb'
272
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/search/search_helper.rb',
272
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/search/search_helper.rb',
273
273
  'app/helpers/search_helper.rb'
274
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/search/index.html.erb',
274
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/search/index.html.erb',
275
275
  'app/views/search/index.html.erb'
276
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/search/search_controller_test.rb',
276
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/search/search_controller_test.rb',
277
277
  'test/controllers/search_controller_test.rb'
278
278
  end
279
279
 
@@ -301,13 +301,13 @@ if ENV['LOCAL']
301
301
  copy_file File.expand_path('../assets/form.css', __FILE__), 'app/assets/stylesheets/form.css'
302
302
  copy_file File.expand_path('../assets/blank_cover.png', __FILE__), 'public/images/blank_cover.png'
303
303
  else
304
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/assets/application.css',
304
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/assets/application.css',
305
305
  'app/assets/stylesheets/application.css'
306
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/assets/autocomplete.css',
306
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/assets/autocomplete.css',
307
307
  'app/assets/stylesheets/autocomplete.css'
308
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/assets/form.css',
308
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/assets/form.css',
309
309
  'app/assets/stylesheets/form.css'
310
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/assets/blank_cover.png',
310
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/assets/blank_cover.png',
311
311
  'public/images/blank_cover.png'
312
312
  end
313
313
 
@@ -343,7 +343,7 @@ puts '-'*80, ''; sleep 0.25
343
343
  if ENV['LOCAL']
344
344
  copy_file File.expand_path('../index_manager.rb', __FILE__), 'lib/index_manager.rb'
345
345
  else
346
- get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/index_manager.rb',
346
+ get 'https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/master/elasticsearch-persistence/examples/music/index_manager.rb',
347
347
  'lib/index_manager.rb'
348
348
  end
349
349
 
@@ -25,6 +25,12 @@ module Elasticsearch
25
25
  @_id
26
26
  end; alias :_id :id
27
27
 
28
+ # Set the document `_id`
29
+ #
30
+ def id=(value)
31
+ @_id = value
32
+ end; alias :_id= :id=
33
+
28
34
  # Return the document `_index`
29
35
  #
30
36
  def _index
@@ -45,7 +51,7 @@ module Elasticsearch
45
51
 
46
52
  def to_s
47
53
  "#<#{self.class} #{attributes.to_hash.inspect.gsub(/:(\w+)=>/, '\1: ')}>"
48
- end
54
+ end; alias :inspect :to_s
49
55
  end
50
56
  end
51
57
 
@@ -1,5 +1,5 @@
1
1
  module Elasticsearch
2
2
  module Persistence
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
@@ -8,10 +8,17 @@ require 'simplecov' and SimpleCov.start { add_filter "/test|test_/" } if ENV["CO
8
8
  # MUST be called before requiring `test/unit`.
9
9
  at_exit { Elasticsearch::Test::IntegrationTestCase.__run_at_exit_hooks } if ENV['SERVER']
10
10
 
11
- require 'test/unit'
11
+ if defined?(RUBY_VERSION) && RUBY_VERSION > '2.2'
12
+ require 'test-unit'
13
+ require 'mocha/test_unit'
14
+ else
15
+ require 'minitest/autorun'
16
+ require 'mocha/mini_test'
17
+ end
18
+
12
19
  require 'shoulda-context'
13
- require 'mocha/setup'
14
- require 'turn' unless ENV["TM_FILEPATH"] || ENV["NOTURN"] || RUBY_1_8
20
+
21
+ require 'turn' unless ENV["TM_FILEPATH"] || ENV["NOTURN"] || defined?(RUBY_VERSION) && RUBY_VERSION > '2.2'
15
22
 
16
23
  require 'ansi'
17
24
  require 'oj'
@@ -27,6 +27,14 @@ class Elasticsearch::Persistence::ModelBaseTest < Test::Unit::TestCase
27
27
  assert_equal 2, m.id
28
28
  end
29
29
 
30
+ should "set the ID using setter method" do
31
+ m = DummyBaseModel.new id: 1
32
+ assert_equal 1, m.id
33
+
34
+ m.id = 2
35
+ assert_equal 2, m.id
36
+ end
37
+
30
38
  should "have ID in attributes" do
31
39
  m = DummyBaseModel.new id: 1, name: 'Test'
32
40
  assert_equal 1, m.attributes[:id]
@@ -93,6 +93,7 @@ class Elasticsearch::Persistence::ModelFindTest < Test::Unit::TestCase
93
93
  assert_equal 'scan', arguments[:search_type]
94
94
  assert_equal 'foo', arguments[:index]
95
95
  assert_equal 'bar', arguments[:type]
96
+ true
96
97
  end
97
98
  .returns(MultiJson.load('{"_scroll_id":"abc123==", "hits":{"hits":[]}}'))
98
99
 
@@ -76,6 +76,7 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
76
76
  .with do |object, options|
77
77
  assert_equal subject, object
78
78
  assert_equal nil, options[:id]
79
+ true
79
80
  end
80
81
  .returns({'_id' => 'abc123'})
81
82
 
@@ -97,7 +98,8 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
97
98
  end
98
99
 
99
100
  should "save the model and update the timestamp" do
100
- Time.expects(:now).returns(Time.parse('2014-01-01T00:00:00Z')).at_least_once
101
+ now = Time.parse('2014-01-01T00:00:00Z')
102
+ Time.expects(:now).returns(now).at_least_once
101
103
  @gateway
102
104
  .expects(:save)
103
105
  .returns({'_id' => 'abc123'})
@@ -111,6 +113,7 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
111
113
  .expects(:save)
112
114
  .with do |object, options|
113
115
  assert_equal 'ABC', options[:routing]
116
+ true
114
117
  end
115
118
  .returns({'_id' => 'abc123'})
116
119
 
@@ -141,6 +144,7 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
141
144
  .with do |model, options|
142
145
  assert_equal 'my_custom_index', options[:index]
143
146
  assert_equal 'my_custom_type', options[:type]
147
+ true
144
148
  end
145
149
  .returns({'_id' => 'abc'})
146
150
 
@@ -155,6 +159,7 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
155
159
  .with do |model, options|
156
160
  assert_equal 'my_custom_index', options[:index]
157
161
  assert_equal 'my_custom_type', options[:type]
162
+ true
158
163
  end
159
164
  .returns({'_id' => 'abc', '_index' => 'foo', '_type' => 'bar', '_version' => '100'})
160
165
 
@@ -192,6 +197,7 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
192
197
  .expects(:delete)
193
198
  .with do |object, options|
194
199
  assert_equal 'ABC', options[:routing]
200
+ true
195
201
  end
196
202
  .returns({'_id' => 'abc123'})
197
203
 
@@ -228,6 +234,7 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
228
234
  .with do |model, options|
229
235
  assert_equal 'my_custom_index', options[:index]
230
236
  assert_equal 'my_custom_type', options[:type]
237
+ true
231
238
  end
232
239
  .returns({'_id' => 'abc'})
233
240
 
@@ -251,6 +258,7 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
251
258
  .with do |id, options|
252
259
  assert_equal 'abc123', id
253
260
  assert_equal 'UPDATED', options[:doc][:title]
261
+ true
254
262
  end
255
263
  .returns({'_id' => 'abc123', 'version' => 2})
256
264
 
@@ -268,6 +276,7 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
268
276
  .with do |id, options|
269
277
  assert_equal 'abc123', id
270
278
  assert_equal 'EXEC', options[:script]
279
+ true
271
280
  end
272
281
  .returns({'_id' => 'abc123', 'version' => 2})
273
282
 
@@ -281,6 +290,7 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
281
290
  .expects(:update)
282
291
  .with do |object, options|
283
292
  assert_equal 'ABC', options[:routing]
293
+ true
284
294
  end
285
295
  .returns({'_id' => 'abc123'})
286
296
 
@@ -314,6 +324,7 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
314
324
  .with do |model, options|
315
325
  assert_equal 'my_custom_index', options[:index]
316
326
  assert_equal 'my_custom_type', options[:type]
327
+ true
317
328
  end
318
329
  .returns({'_id' => 'abc'})
319
330
 
@@ -330,6 +341,7 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
330
341
  .with do |model, options|
331
342
  assert_equal 'my_custom_index', options[:index]
332
343
  assert_equal 'my_custom_type', options[:type]
344
+ true
333
345
  end
334
346
  .returns({'_id' => 'abc', '_index' => 'foo', '_type' => 'bar', '_version' => '100'})
335
347
 
@@ -354,6 +366,7 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
354
366
  .expects(:update)
355
367
  .with do |id, options|
356
368
  assert_equal 'ctx._source.count += 1', options[:script]
369
+ true
357
370
  end
358
371
  .returns({'_id' => 'abc123', 'version' => 2})
359
372
 
@@ -369,6 +382,7 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
369
382
  .with do |model, options|
370
383
  assert_equal 'my_custom_index', options[:index]
371
384
  assert_equal 'my_custom_type', options[:type]
385
+ true
372
386
  end
373
387
  .returns({'_id' => 'abc', '_index' => 'foo', '_type' => 'bar', '_version' => '100'})
374
388
 
@@ -391,6 +405,7 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
391
405
  .expects(:update)
392
406
  .with do |id, options|
393
407
  assert_equal 'ctx._source.count = ctx._source.count - 1', options[:script]
408
+ true
394
409
  end
395
410
  .returns({'_id' => 'abc123', 'version' => 2})
396
411
 
@@ -406,6 +421,7 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
406
421
  .with do |model, options|
407
422
  assert_equal 'my_custom_index', options[:index]
408
423
  assert_equal 'my_custom_type', options[:type]
424
+ true
409
425
  end
410
426
  .returns({'_id' => 'abc', '_index' => 'foo', '_type' => 'bar', '_version' => '100'})
411
427
 
@@ -428,12 +444,14 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
428
444
 
429
445
  should "update updated_at by default" do
430
446
  subject.expects(:persisted?).returns(true)
431
- Time.expects(:now).returns(Time.parse('2014-01-01T00:00:00Z')).at_least_once
447
+ now = Time.parse('2014-01-01T00:00:00Z')
448
+ Time.expects(:now).returns(now).at_least_once
432
449
 
433
450
  @gateway
434
451
  .expects(:update)
435
452
  .with do |id, options|
436
453
  assert_equal '2014-01-01T00:00:00Z', options[:doc][:updated_at]
454
+ true
437
455
  end
438
456
  .returns({'_id' => 'abc123', 'version' => 2})
439
457
 
@@ -443,12 +461,14 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
443
461
 
444
462
  should "update a custom attribute by default" do
445
463
  subject.expects(:persisted?).returns(true)
446
- Time.expects(:now).returns(Time.parse('2014-01-01T00:00:00Z')).at_least_once
464
+ now = Time.parse('2014-01-01T00:00:00Z')
465
+ Time.expects(:now).returns(now).at_least_once
447
466
 
448
467
  @gateway
449
468
  .expects(:update)
450
469
  .with do |id, options|
451
470
  assert_equal '2014-01-01T00:00:00Z', options[:doc][:created_at]
471
+ true
452
472
  end
453
473
  .returns({'_id' => 'abc123', 'version' => 2})
454
474
 
@@ -475,6 +495,7 @@ class Elasticsearch::Persistence::ModelStoreTest < Test::Unit::TestCase
475
495
  .with do |model, options|
476
496
  assert_equal 'my_custom_index', options[:index]
477
497
  assert_equal 'my_custom_type', options[:type]
498
+ true
478
499
  end
479
500
  .returns({'_id' => 'abc', '_index' => 'foo', '_type' => 'bar', '_version' => '100'})
480
501
 
@@ -58,6 +58,7 @@ class Elasticsearch::Persistence::RepositoryFindTest < Test::Unit::TestCase
58
58
  .with do |arguments|
59
59
  assert_equal 'my_document', arguments[:type]
60
60
  assert_equal '1', arguments[:id]
61
+ true
61
62
  end
62
63
  .returns(true)
63
64
 
@@ -74,6 +75,7 @@ class Elasticsearch::Persistence::RepositoryFindTest < Test::Unit::TestCase
74
75
  .with do |arguments|
75
76
  assert_equal 'my_document', arguments[:type]
76
77
  assert_equal '1', arguments[:id]
78
+ true
77
79
  end
78
80
  .returns(true)
79
81
 
@@ -89,6 +91,7 @@ class Elasticsearch::Persistence::RepositoryFindTest < Test::Unit::TestCase
89
91
  .with do |arguments|
90
92
  assert_equal '_all', arguments[:type]
91
93
  assert_equal '1', arguments[:id]
94
+ true
92
95
  end
93
96
  .returns(true)
94
97
 
@@ -99,6 +102,7 @@ class Elasticsearch::Persistence::RepositoryFindTest < Test::Unit::TestCase
99
102
  @client.expects(:exists).with do |arguments|
100
103
  assert_equal 'foobarbam', arguments[:index]
101
104
  assert_equal 'bambam', arguments[:routing]
105
+ true
102
106
  end
103
107
 
104
108
  subject.exists? '1', index: 'foobarbam', routing: 'bambam'
@@ -118,6 +122,7 @@ class Elasticsearch::Persistence::RepositoryFindTest < Test::Unit::TestCase
118
122
  .with do |arguments|
119
123
  assert_equal 'my_document', arguments[:type]
120
124
  assert_equal '1', arguments[:id]
125
+ true
121
126
  end
122
127
  .returns({'_source' => { 'foo' => 'bar' }})
123
128
 
@@ -136,6 +141,7 @@ class Elasticsearch::Persistence::RepositoryFindTest < Test::Unit::TestCase
136
141
  .with do |arguments|
137
142
  assert_equal 'my_document', arguments[:type]
138
143
  assert_equal '1', arguments[:id]
144
+ true
139
145
  end
140
146
  .returns({'_source' => { 'foo' => 'bar' }})
141
147
 
@@ -154,6 +160,7 @@ class Elasticsearch::Persistence::RepositoryFindTest < Test::Unit::TestCase
154
160
  .with do |arguments|
155
161
  assert_equal '_all', arguments[:type]
156
162
  assert_equal '1', arguments[:id]
163
+ true
157
164
  end
158
165
  .returns({'_source' => { 'foo' => 'bar' }})
159
166
 
@@ -198,6 +205,7 @@ class Elasticsearch::Persistence::RepositoryFindTest < Test::Unit::TestCase
198
205
  .with do |arguments|
199
206
  assert_equal 'foobarbam', arguments[:index]
200
207
  assert_equal 'bambam', arguments[:routing]
208
+ true
201
209
  end
202
210
  .returns({'_source' => { 'foo' => 'bar' }})
203
211
 
@@ -244,6 +252,7 @@ class Elasticsearch::Persistence::RepositoryFindTest < Test::Unit::TestCase
244
252
  .with do |arguments|
245
253
  assert_equal 'my_document', arguments[:type]
246
254
  assert_equal ['1', '2'], arguments[:body][:ids]
255
+ true
247
256
  end
248
257
  .returns(@response)
249
258
 
@@ -264,6 +273,7 @@ class Elasticsearch::Persistence::RepositoryFindTest < Test::Unit::TestCase
264
273
  .with do |arguments|
265
274
  assert_equal 'my_document', arguments[:type]
266
275
  assert_equal ['1', '2'], arguments[:body][:ids]
276
+ true
267
277
  end
268
278
  .returns(@response)
269
279
 
@@ -290,6 +300,7 @@ class Elasticsearch::Persistence::RepositoryFindTest < Test::Unit::TestCase
290
300
  .with do |arguments|
291
301
  assert_equal '_all', arguments[:type]
292
302
  assert_equal ['1', '2'], arguments[:body][:ids]
303
+ true
293
304
  end
294
305
  .returns(@response)
295
306
 
@@ -343,6 +354,7 @@ class Elasticsearch::Persistence::RepositoryFindTest < Test::Unit::TestCase
343
354
  .with do |arguments|
344
355
  assert_equal 'my_document', arguments[:type]
345
356
  assert_equal ['1', '3', '2'], arguments[:body][:ids]
357
+ true
346
358
  end
347
359
  .returns(@response)
348
360
 
@@ -364,6 +376,7 @@ class Elasticsearch::Persistence::RepositoryFindTest < Test::Unit::TestCase
364
376
  .with do |arguments|
365
377
  assert_equal 'foobarbam', arguments[:index]
366
378
  assert_equal 'bambam', arguments[:routing]
379
+ true
367
380
  end
368
381
  .returns(@response)
369
382
 
@@ -104,6 +104,7 @@ class Elasticsearch::Persistence::RepositoryModuleTest < Test::Unit::TestCase
104
104
  client.expects(:index).with do |arguments|
105
105
  assert_equal('xxx', arguments[:id])
106
106
  assert_equal('FAKE!', arguments[:body])
107
+ true
107
108
  end
108
109
  repository.gateway.expects(:client).returns(client)
109
110
 
@@ -129,6 +130,7 @@ class Elasticsearch::Persistence::RepositoryModuleTest < Test::Unit::TestCase
129
130
  client.expects(:index).with do |arguments|
130
131
  assert_equal('xxx', arguments[:id])
131
132
  assert_equal('FAKE IN CLASS!', arguments[:body])
133
+ true
132
134
  end
133
135
  repository.gateway.expects(:client).returns(client)
134
136
 
@@ -21,8 +21,8 @@ class Elasticsearch::Persistence::RepositorySearchTest < Test::Unit::TestCase
21
21
  @client.expects(:search).with do |arguments|
22
22
  assert_equal 'test', arguments[:index]
23
23
  assert_equal 'my_document', arguments[:type]
24
-
25
- assert_equal({foo: 'bar'}, arguments[:body])
24
+ assert_equal({foo: 'bar'}, arguments[:body])
25
+ true
26
26
  end
27
27
 
28
28
  subject.search foo: 'bar'
@@ -35,8 +35,8 @@ class Elasticsearch::Persistence::RepositorySearchTest < Test::Unit::TestCase
35
35
  @client.expects(:search).with do |arguments|
36
36
  assert_equal 'test', arguments[:index]
37
37
  assert_equal 'my_special_document', arguments[:type]
38
-
39
- assert_equal({foo: 'bar'}, arguments[:body])
38
+ assert_equal({foo: 'bar'}, arguments[:body])
39
+ true
40
40
  end
41
41
 
42
42
  subject.search foo: 'bar'
@@ -50,8 +50,8 @@ class Elasticsearch::Persistence::RepositorySearchTest < Test::Unit::TestCase
50
50
  @client.expects(:search).with do |arguments|
51
51
  assert_equal 'test', arguments[:index]
52
52
  assert_equal nil, arguments[:type]
53
-
54
53
  assert_equal({foo: 'bar'}, arguments[:body])
54
+ true
55
55
  end
56
56
 
57
57
  assert_instance_of Elasticsearch::Persistence::Repository::Response::Results,
@@ -64,6 +64,7 @@ class Elasticsearch::Persistence::RepositorySearchTest < Test::Unit::TestCase
64
64
 
65
65
  @client.expects(:search).twice.with do |arguments|
66
66
  assert_equal 'bambam', arguments[:routing]
67
+ true
67
68
  end
68
69
 
69
70
  assert_instance_of Elasticsearch::Persistence::Repository::Response::Results,
@@ -78,6 +79,7 @@ class Elasticsearch::Persistence::RepositorySearchTest < Test::Unit::TestCase
78
79
 
79
80
  @client.expects(:search).with do |arguments|
80
81
  assert_equal 'foobar', arguments[:q]
82
+ true
81
83
  end
82
84
 
83
85
  assert_instance_of Elasticsearch::Persistence::Repository::Response::Results,
@@ -104,6 +106,7 @@ class Elasticsearch::Persistence::RepositorySearchTest < Test::Unit::TestCase
104
106
  .with do |query_or_definition, options|
105
107
  assert_equal 'bar', query_or_definition[:query][:match][:foo]
106
108
  assert_equal true, options[:ignore_unavailable]
109
+ true
107
110
  end
108
111
  .returns(Elasticsearch::Persistence::Repository::Response::Results.new( subject, {'hits' => { 'total' => 1 }}))
109
112
 
@@ -25,6 +25,7 @@ class Elasticsearch::Persistence::RepositoryStoreTest < Test::Unit::TestCase
25
25
  assert_equal 'my_document', arguments[:type]
26
26
  assert_equal '1', arguments[:id]
27
27
  assert_equal({foo: 'bar'}, arguments[:body])
28
+ true
28
29
  end
29
30
  subject.expects(:client).returns(client)
30
31
 
@@ -43,6 +44,7 @@ class Elasticsearch::Persistence::RepositoryStoreTest < Test::Unit::TestCase
43
44
  assert_equal 'my_document', arguments[:type]
44
45
  assert_equal '1', arguments[:id]
45
46
  assert_equal({foo: 'bar'}, arguments[:body])
47
+ true
46
48
  end
47
49
  subject.expects(:client).returns(client)
48
50
 
@@ -64,6 +66,7 @@ class Elasticsearch::Persistence::RepositoryStoreTest < Test::Unit::TestCase
64
66
  assert_equal 'my_document', arguments[:type]
65
67
  assert_equal '1', arguments[:id]
66
68
  assert_equal({foo: 'bar'}, arguments[:body])
69
+ true
67
70
  end
68
71
  subject.expects(:client).returns(client)
69
72
 
@@ -81,6 +84,7 @@ class Elasticsearch::Persistence::RepositoryStoreTest < Test::Unit::TestCase
81
84
  client.expects(:index).with do |arguments|
82
85
  assert_equal 'foobarbam', arguments[:index]
83
86
  assert_equal 'bambam', arguments[:routing]
87
+ true
84
88
  end
85
89
  subject.expects(:client).returns(client)
86
90
 
@@ -99,6 +103,7 @@ class Elasticsearch::Persistence::RepositoryStoreTest < Test::Unit::TestCase
99
103
  assert_equal '1', arguments[:id]
100
104
  assert_equal 'mydoc', arguments[:type]
101
105
  assert_equal({doc: { foo: 'bar' }}, arguments[:body])
106
+ true
102
107
  end
103
108
  subject.expects(:client).returns(client)
104
109
 
@@ -114,6 +119,7 @@ class Elasticsearch::Persistence::RepositoryStoreTest < Test::Unit::TestCase
114
119
  assert_equal '1', arguments[:id]
115
120
  assert_equal 'mydoc', arguments[:type]
116
121
  assert_equal({script: 'ctx._source.foo += 1'}, arguments[:body])
122
+ true
117
123
  end
118
124
  subject.expects(:client).returns(client)
119
125
 
@@ -129,6 +135,7 @@ class Elasticsearch::Persistence::RepositoryStoreTest < Test::Unit::TestCase
129
135
  assert_equal '1', arguments[:id]
130
136
  assert_equal 'mydoc', arguments[:type]
131
137
  assert_equal({script: 'ctx._source.foo += 1', upsert: { foo: 1 }}, arguments[:body])
138
+ true
132
139
  end
133
140
  subject.expects(:client).returns(client)
134
141
 
@@ -143,6 +150,7 @@ class Elasticsearch::Persistence::RepositoryStoreTest < Test::Unit::TestCase
143
150
  assert_equal '1', arguments[:id]
144
151
  assert_equal 'mydoc', arguments[:type]
145
152
  assert_equal({doc: { foo: 'bar' }}, arguments[:body])
153
+ true
146
154
  end
147
155
  subject.expects(:client).returns(client)
148
156
 
@@ -157,6 +165,7 @@ class Elasticsearch::Persistence::RepositoryStoreTest < Test::Unit::TestCase
157
165
  assert_equal '1', arguments[:id]
158
166
  assert_equal 'mydoc', arguments[:type]
159
167
  assert_equal({script: 'ctx._source.foo += 1'}, arguments[:body])
168
+ true
160
169
  end
161
170
  subject.expects(:client).returns(client)
162
171
 
@@ -171,6 +180,7 @@ class Elasticsearch::Persistence::RepositoryStoreTest < Test::Unit::TestCase
171
180
  assert_equal '1', arguments[:id]
172
181
  assert_equal 'mydoc', arguments[:type]
173
182
  assert_equal({script: 'ctx._source.foo += 1', upsert: { foo: 1 } }, arguments[:body])
183
+ true
174
184
  end
175
185
  subject.expects(:client).returns(client)
176
186
 
@@ -185,6 +195,7 @@ class Elasticsearch::Persistence::RepositoryStoreTest < Test::Unit::TestCase
185
195
  assert_equal '1', arguments[:id]
186
196
  assert_equal 'foo', arguments[:type]
187
197
  assert_equal({script: 'ctx._source.foo += 1'}, arguments[:body])
198
+ true
188
199
  end
189
200
  subject.expects(:client).returns(client)
190
201
 
@@ -208,6 +219,7 @@ class Elasticsearch::Persistence::RepositoryStoreTest < Test::Unit::TestCase
208
219
  client.expects(:delete).with do |arguments|
209
220
  assert_equal 'my_document', arguments[:type]
210
221
  assert_equal '1', arguments[:id]
222
+ true
211
223
  end
212
224
  subject.expects(:client).returns(client)
213
225
 
@@ -225,6 +237,7 @@ class Elasticsearch::Persistence::RepositoryStoreTest < Test::Unit::TestCase
225
237
  client.expects(:delete).with do |arguments|
226
238
  assert_equal 'my_document', arguments[:type]
227
239
  assert_equal '1', arguments[:id]
240
+ true
228
241
  end
229
242
  subject.expects(:client).returns(client)
230
243
 
@@ -245,6 +258,7 @@ class Elasticsearch::Persistence::RepositoryStoreTest < Test::Unit::TestCase
245
258
  client.expects(:delete).with do |arguments|
246
259
  assert_equal 'my_document', arguments[:type]
247
260
  assert_equal '1', arguments[:id]
261
+ true
248
262
  end
249
263
  subject.expects(:client).returns(client)
250
264
 
@@ -262,6 +276,7 @@ class Elasticsearch::Persistence::RepositoryStoreTest < Test::Unit::TestCase
262
276
  client.expects(:delete).with do |arguments|
263
277
  assert_equal 'my_document', arguments[:type]
264
278
  assert_equal '1', arguments[:id]
279
+ true
265
280
  end
266
281
  subject.expects(:client).returns(client)
267
282
 
@@ -277,6 +292,7 @@ class Elasticsearch::Persistence::RepositoryStoreTest < Test::Unit::TestCase
277
292
  client.expects(:delete).with do |arguments|
278
293
  assert_equal 'foobarbam', arguments[:index]
279
294
  assert_equal 'bambam', arguments[:routing]
295
+ true
280
296
  end
281
297
  subject.expects(:client).returns(client)
282
298
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-persistence
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-18 00:00:00.000000000 Z
11
+ date: 2014-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elasticsearch
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - ! '>='
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: minitest
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: '4'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ~>
179
+ - !ruby/object:Gem::Version
180
+ version: '4'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: shoulda-context
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -252,16 +266,16 @@ dependencies:
252
266
  name: ci_reporter
253
267
  requirement: !ruby/object:Gem::Requirement
254
268
  requirements:
255
- - - ! '>='
269
+ - - ~>
256
270
  - !ruby/object:Gem::Version
257
- version: '0'
271
+ version: '1.9'
258
272
  type: :development
259
273
  prerelease: false
260
274
  version_requirements: !ruby/object:Gem::Requirement
261
275
  requirements:
262
- - - ! '>='
276
+ - - ~>
263
277
  - !ruby/object:Gem::Version
264
- version: '0'
278
+ version: '1.9'
265
279
  - !ruby/object:Gem::Dependency
266
280
  name: simplecov
267
281
  requirement: !ruby/object:Gem::Requirement