elastic_record 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -6
  3. data/Gemfile +0 -2
  4. data/README.md +25 -9
  5. data/elastic_record.gemspec +1 -1
  6. data/lib/elastic_record/as_document.rb +41 -0
  7. data/lib/elastic_record/callbacks.rb +11 -56
  8. data/lib/elastic_record/connection.rb +1 -1
  9. data/lib/elastic_record/doctype.rb +43 -0
  10. data/lib/elastic_record/index/deferred.rb +13 -15
  11. data/lib/elastic_record/index/documents.rb +23 -13
  12. data/lib/elastic_record/index/manage.rb +4 -6
  13. data/lib/elastic_record/index/mapping.rb +7 -26
  14. data/lib/elastic_record/index/settings.rb +17 -2
  15. data/lib/elastic_record/index.rb +12 -24
  16. data/lib/elastic_record/model.rb +14 -4
  17. data/lib/elastic_record/percolator_model.rb +44 -0
  18. data/lib/elastic_record/relation.rb +1 -2
  19. data/lib/elastic_record/searching.rb +5 -1
  20. data/lib/elastic_record/tasks/index.rake +0 -10
  21. data/lib/elastic_record.rb +3 -0
  22. data/test/dummy/app/models/mock_model.rb +108 -0
  23. data/test/dummy/app/models/project.rb +1 -1
  24. data/test/dummy/app/models/test_model.rb +1 -102
  25. data/test/dummy/app/models/test_percolator_model.rb +8 -0
  26. data/test/dummy/app/models/widget.rb +2 -5
  27. data/test/dummy/app/models/widget_query.rb +14 -0
  28. data/test/dummy/config/environments/test.rb +3 -3
  29. data/test/dummy/config/initializers/elastic_record.rb +1 -1
  30. data/test/elastic_record/as_document_test.rb +65 -0
  31. data/test/elastic_record/callbacks_test.rb +6 -81
  32. data/test/elastic_record/config_test.rb +1 -1
  33. data/test/elastic_record/doctype_test.rb +45 -0
  34. data/test/elastic_record/index/documents_test.rb +1 -1
  35. data/test/elastic_record/index/mapping_test.rb +16 -13
  36. data/test/elastic_record/index/settings_test.rb +34 -1
  37. data/test/elastic_record/index_test.rb +7 -15
  38. data/test/elastic_record/model_test.rb +1 -7
  39. data/test/elastic_record/percolator_model_test.rb +54 -0
  40. data/test/elastic_record/relation/batches_test.rb +0 -1
  41. data/test/elastic_record/relation/delegation_test.rb +0 -1
  42. data/test/elastic_record/relation/finder_methods_test.rb +0 -1
  43. data/test/elastic_record/relation_test.rb +0 -2
  44. data/test/elastic_record/searching_test.rb +7 -0
  45. metadata +11 -10
  46. data/lib/elastic_record/index/configurator.rb +0 -18
  47. data/lib/elastic_record/index/percolator.rb +0 -50
  48. data/lib/elastic_record/index/warmer.rb +0 -24
  49. data/lib/elastic_record/relation/admin.rb +0 -13
  50. data/test/elastic_record/index/configurator_test.rb +0 -18
  51. data/test/elastic_record/index/percolator_test.rb +0 -45
  52. data/test/elastic_record/index/warmer_test.rb +0 -20
  53. data/test/elastic_record/relation/admin_test.rb +0 -28
@@ -1,20 +0,0 @@
1
- require 'helper'
2
-
3
- class ElasticRecord::Index::WarmerTest < MiniTest::Test
4
- def test_create_warmer
5
- index.delete_warmer('green') if index.warmer_exists?('green')
6
- refute index.warmer_exists?('green')
7
-
8
- index.create_warmer('green', 'query' => { "match_all" => {} })
9
-
10
- assert index.warmer_exists?('green')
11
- expected = {"types" => ["widget"], "source" => {"query" => {"match_all"=>{}}}}
12
- assert_equal expected, index.get_warmer('green')
13
- end
14
-
15
- private
16
-
17
- def index
18
- Widget.elastic_index
19
- end
20
- end
@@ -1,28 +0,0 @@
1
- require 'helper'
2
-
3
- class ElasticRecord::Relation::AdminTest < MiniTest::Test
4
- def test_create_percolator
5
- index.delete_percolator('green') if index.percolator_exists?('green')
6
-
7
- relation = Widget.elastic_relation.filter('color' => 'green')
8
- relation.create_percolator('green')
9
-
10
- assert_equal relation.as_elastic, index.get_percolator('green')
11
- end
12
-
13
- def test_create_warmer
14
- index.delete_warmer('green') if index.warmer_exists?('green')
15
-
16
- relation = Widget.elastic_relation.filter('color' => 'green')
17
- relation.create_warmer('green')
18
-
19
- assert_equal relation.as_elastic, Widget.elastic_index.get_warmer('green')['source']
20
- end
21
-
22
- private
23
-
24
- def index
25
- Widget.elastic_index
26
- end
27
-
28
- end