test/index_test.rb in searchkick-0.7.4 vs test/index_test.rb in searchkick-0.7.5

- old
+ new

@@ -33,9 +33,38 @@ store_names ["Dollar Tree"], Store assert_equal [], Store.search(query: {match: {name: "dollar"}}).map(&:name) assert_equal ["Dollar Tree"], Store.search(query: {match: {name: "Dollar Tree"}}).map(&:name) end + def test_record_not_found + store_names ["Product A", "Product B"] + Product.where(name: "Product A").delete_all + assert_search "product", ["Product B"] + end + + def test_bad_mapping + Product.searchkick_index.delete + store_names ["Product A"] + assert_raises(Searchkick::InvalidQueryError){ Product.search "test" } + ensure + Product.reindex + end + + def test_missing_index + assert_raises(Searchkick::MissingIndexError){ Product.search "test", index_name: "not_found" } + end + + def test_unsupported_version + raises_exception = lambda { |s| raise Elasticsearch::Transport::Transport::Error.new("[500] No query registered for [multi_match]") } + Searchkick.client.stub :search, raises_exception do + assert_raises(Searchkick::UnsupportedVersionError){ Product.search("test") } + end + end + + def test_invalid_query + assert_raises(Searchkick::InvalidQueryError){ Product.search(query: {}) } + end + if defined?(ActiveRecord) def test_transaction Product.transaction do store_names ["Product A"]