Commit 7cc2545d07521f0f8b6d78893efa2a1bd4f25444

Authored by Andrew Kane
1 parent b0be1bcf

Reorganized tests [skip ci]

Showing 1 changed file with 15 additions and 13 deletions   Show diff stats
test/index_test.rb
... ... @@ -6,6 +6,19 @@ class IndexTest < Minitest::Test
6 6 Region.destroy_all
7 7 end
8 8  
  9 + def test_tokens
  10 + assert_equal ["dollar", "dollartre", "tree"], Product.search_index.tokens("Dollar Tree", analyzer: "searchkick_index")
  11 + end
  12 +
  13 + def test_tokens_analyzer
  14 + assert_equal ["dollar", "tree"], Product.search_index.tokens("Dollar Tree", analyzer: "searchkick_search2")
  15 + end
  16 +
  17 + def test_total_docs
  18 + store_names ["Product A"]
  19 + assert_equal 1, Product.search_index.total_docs
  20 + end
  21 +
9 22 def test_clean_indices
10 23 suffix = Searchkick.index_suffix ? "_#{Searchkick.index_suffix}" : ""
11 24 old_index = Searchkick::Index.new("products_test#{suffix}_20130801000000000")
... ... @@ -42,11 +55,6 @@ class IndexTest < Minitest::Test
42 55 assert_equal 2, Product.search_index.all_indices.size
43 56 end
44 57  
45   - def test_total_docs
46   - store_names ["Product A"]
47   - assert_equal 1, Product.search_index.total_docs
48   - end
49   -
50 58 def test_mappings
51 59 store_names ["Dollar Tree"], Store
52 60 assert_equal ["Dollar Tree"], Store.search(body: {query: {match: {name: "dollar"}}}).map(&:name)
... ... @@ -55,14 +63,6 @@ class IndexTest < Minitest::Test
55 63 assert_equal "text", mapping["properties"]["name"]["type"]
56 64 end
57 65  
58   - def test_tokens
59   - assert_equal ["dollar", "dollartre", "tree"], Product.search_index.tokens("Dollar Tree", analyzer: "searchkick_index")
60   - end
61   -
62   - def test_tokens_analyzer
63   - assert_equal ["dollar", "tree"], Product.search_index.tokens("Dollar Tree", analyzer: "searchkick_search2")
64   - end
65   -
66 66 def test_remove_blank_id
67 67 store_names ["Product A"]
68 68 Product.search_index.remove(Product.new)
... ... @@ -71,6 +71,8 @@ class IndexTest < Minitest::Test
71 71 Product.reindex
72 72 end
73 73  
  74 + # TODO move
  75 +
74 76 def test_filterable
75 77 # skip for 5.0 since it throws
76 78 # Cannot search on field [alt_description] since it is not indexed.
... ...