routing_test.rb
1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require_relative "test_helper"
class RoutingTest < Minitest::Test
def test_query
query = Store.search("Dollar Tree", routing: "Dollar Tree")
assert_equal query.params[:routing], "Dollar Tree"
end
def test_mappings
mappings = Store.search_index.index_options[:mappings]
assert_equal mappings[:_routing], required: true
end
def test_correct_node
store_names ["Dollar Tree"], Store
assert_search "*", ["Dollar Tree"], {routing: "Dollar Tree"}, Store
end
def test_incorrect_node
store_names ["Dollar Tree"], Store
assert_search "*", ["Dollar Tree"], {routing: "Boom"}, Store
end
def test_async
with_options({routing: true, callbacks: :async}, Song) do
store_names ["Dollar Tree"], Song
Song.destroy_all
end
end
def test_queue
with_options({routing: true, callbacks: :queue}, Song) do
store_names ["Dollar Tree"], Song
Song.destroy_all
Searchkick::ProcessQueueJob.perform_later(class_name: "Song")
end
end
end