From 5979937ea9640ef6921a98b846589a025690396e Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 3 Mar 2022 13:01:56 -0800 Subject: [PATCH] Added tests for index_name and index_prefix options --- test/index_options_test.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+), 0 deletions(-) diff --git a/test/index_options_test.rb b/test/index_options_test.rb index ba97e97..6b46671 100644 --- a/test/index_options_test.rb +++ b/test/index_options_test.rb @@ -3,6 +3,7 @@ require_relative "test_helper" class IndexOptionsTest < Minitest::Test def setup Song.destroy_all + Song.instance_variable_set(:@searchkick_index_name, nil) end def test_case_sensitive @@ -66,6 +67,30 @@ class IndexOptionsTest < Minitest::Test end end + def test_index_name + with_options({index_name: "songs_v2"}) do + assert_equal "songs_v2", Song.search_index.name + end + end + + def test_index_name_callable + with_options({index_name: -> { "songs_v2" }}) do + assert_equal "songs_v2", Song.search_index.name + end + end + + def test_index_prefix + with_options({index_prefix: "hello"}) do + assert_equal "hello_songs_test", Song.search_index.name + end + end + + def test_index_prefix_callable + with_options({index_prefix: -> { "hello" }}) do + assert_equal "hello_songs_test", Song.search_index.name + end + end + def default_model Song end -- libgit2 0.21.0