You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
disable_indexing option is not being read consistently by #algolia_indexing_disabled? resulting indexing happening in the test suite.
Have a very simple setup at this point. One model, Manufacturer. These are the settings/options we are passing.
class Manufacturer
algoliasearch index_name: "Manufacturer", per_environment: true, raise_on_failure: true, disable_indexing: Rails.env.test? do
# ...
end
end
The result when I run a test that creates a Manufacturer is:
Failure/Error: let(:manufacturer) { create(:manufacturer) }
Algolia::AlgoliaHttpError:
Index not allowed with this API key
I dug into the library a little and found that in #algolia_index! there are three algolia_configurations that are iterated over. The first one has disable_indexing set as a top level key and #algolia_indexing_disabled? returns true. However, in the subsequent algolia_configurations. disable_indexing is set but it's stored as an instance variable on the settings object
algolia_indexing_disabled? doesn't reach all the way into whatever object that is:
def algolia_indexing_disabled?(options = nil)
options ||= algoliasearch_options
constraint = options[:disable_indexing] || options['disable_indexing']
case constraint
when nil
return false
when true, false
# ...
end
end
so options[:disable_indexing] || options['disable_indexing'] returns nil when @options={:index_name=>"Manufacturer", :per_environment=>true, :raise_on_failure=>true, disable_indexing: true}
We're getting around it in the meantime by wrapping the whole algoliasearch block in unless Rails.env.test? but having to include that conditional throughout our business logic when we we need to manually reindex etc is not ideal
The text was updated successfully, but these errors were encountered:
ColinTheRobot
changed the title
disable_indexing not settingdisable_indexing setting not disabling
Sep 12, 2024
Description
disable_indexing
option is not being read consistently by#algolia_indexing_disabled?
resulting indexing happening in the test suite.Have a very simple setup at this point. One model, Manufacturer. These are the settings/options we are passing.
The result when I run a test that creates a Manufacturer is:
I dug into the library a little and found that in
#algolia_index!
there are threealgolia_configurations
that are iterated over. The first one hasdisable_indexing
set as a top level key and#algolia_indexing_disabled?
returns true. However, in the subsequentalgolia_configurations
.disable_indexing
is set but it's stored as an instance variable on the settings objectalgolia_indexing_disabled?
doesn't reach all the way into whatever object that is:so
options[:disable_indexing] || options['disable_indexing']
returns nil when@options={:index_name=>"Manufacturer", :per_environment=>true, :raise_on_failure=>true, disable_indexing: true}
We're getting around it in the meantime by wrapping the whole
algoliasearch
block inunless Rails.env.test?
but having to include that conditional throughout our business logic when we we need to manually reindex etc is not idealThe text was updated successfully, but these errors were encountered: