elastic_record 1.1.8 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/Gemfile +3 -1
- data/elastic_record.gemspec +1 -1
- data/lib/elastic_record/callbacks.rb +2 -0
- data/lib/elastic_record/connection.rb +5 -9
- data/lib/elastic_record/index/mapping.rb +2 -2
- data/lib/elastic_record/model.rb +1 -1
- data/lib/elastic_record/relation/search_methods.rb +0 -9
- data/lib/elastic_record/relation/value_methods.rb +1 -1
- data/lib/elastic_record/relation.rb +7 -26
- data/lib/elastic_record.rb +0 -1
- data/test/elastic_record/config_test.rb +1 -1
- data/test/elastic_record/connection_test.rb +2 -2
- data/test/elastic_record/index/mapping_test.rb +11 -1
- data/test/elastic_record/integration/active_record_test.rb +62 -25
- data/test/elastic_record/relation_test.rb +0 -47
- data/test/helper.rb +1 -7
- data/test/support/models/test_model.rb +1 -19
- data/test/support/models/warehouse.rb +0 -1
- data/test/support/models/widget.rb +0 -2
- metadata +11 -24
- data/lib/elastic_record/searches_many/association.rb +0 -149
- data/lib/elastic_record/searches_many/autosave.rb +0 -72
- data/lib/elastic_record/searches_many/builder.rb +0 -42
- data/lib/elastic_record/searches_many/collection_proxy.rb +0 -26
- data/lib/elastic_record/searches_many/reflection.rb +0 -45
- data/lib/elastic_record/searches_many.rb +0 -100
- data/test/elastic_record/searches_many/association_test.rb +0 -47
- data/test/elastic_record/searches_many/autosave_test.rb +0 -32
- data/test/elastic_record/searches_many/collection_proxy_test.rb +0 -23
- data/test/elastic_record/searches_many/reflection_test.rb +0 -33
- data/test/elastic_record/searches_many_test.rb +0 -76
- data/test/support/models/option.rb +0 -24
- data/test/support/query_counter.rb +0 -56
@@ -1,56 +0,0 @@
|
|
1
|
-
class ElasticSearchCounter
|
2
|
-
class << self
|
3
|
-
attr_accessor :ignored_elastic, :log, :log_all
|
4
|
-
def clear_log; self.log = []; self.log_all = []; end
|
5
|
-
end
|
6
|
-
|
7
|
-
self.clear_log
|
8
|
-
|
9
|
-
self.ignored_elastic = []
|
10
|
-
|
11
|
-
elastic_search_ignored = []
|
12
|
-
|
13
|
-
[elastic_search_ignored].each do |db_ignored_elastic|
|
14
|
-
ignored_elastic.concat db_ignored_elastic
|
15
|
-
end
|
16
|
-
|
17
|
-
attr_reader :ignore
|
18
|
-
|
19
|
-
def initialize(ignore = Regexp.union(self.class.ignored_elastic))
|
20
|
-
@ignore = ignore
|
21
|
-
end
|
22
|
-
|
23
|
-
def call(name, start, finish, message_id, values)
|
24
|
-
self.class.log_all << values
|
25
|
-
self.class.log << values unless ignore =~ values[:request].path
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
ActiveSupport::Notifications.subscribe('request.elastic_record', ElasticSearchCounter.new)
|
30
|
-
|
31
|
-
module MiniTest
|
32
|
-
class Unit
|
33
|
-
class TestCase
|
34
|
-
def assert_queries(num = 1, options = {})
|
35
|
-
ignore_none = options.fetch(:ignore_none) { num == :any }
|
36
|
-
ElasticSearchCounter.clear_log
|
37
|
-
x = yield
|
38
|
-
the_log = ignore_none ? ElasticSearchCounter.log_all : ElasticSearchCounter.log
|
39
|
-
if num == :any
|
40
|
-
assert_operator the_log.size, :>=, 1, "1 or more queries expected, but none were executed."
|
41
|
-
else
|
42
|
-
queries = the_log.map { |event| " #{event[:request].method} #{event[:request].path} #{event[:request].body}\n" }.join("\n")
|
43
|
-
|
44
|
-
mesg = "#{the_log.size} instead of #{num} queries were executed.#{the_log.size == 0 ? '' : "\nQueries:\n#{queries}"}"
|
45
|
-
assert_equal num, the_log.size, mesg
|
46
|
-
end
|
47
|
-
|
48
|
-
x
|
49
|
-
end
|
50
|
-
|
51
|
-
def assert_no_queries(&block)
|
52
|
-
assert_queries(0, :ignore_none => true, &block)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|