diff --git a/spec/support/elasticsearch_helpers.rb b/spec/support/elasticsearch_helpers.rb new file mode 100644 index 000000000..0d89eb33b --- /dev/null +++ b/spec/support/elasticsearch_helpers.rb @@ -0,0 +1,18 @@ +module ElasticsearchHelpers + def sync_elasticsearch(crops) + if ENV['GROWSTUFF_ELASTICSEARCH'] == "true" + crops.each {|crop| crop.__elasticsearch__.index_document} + Crop.__elasticsearch__.refresh_index! + end + end +end + +RSpec.configure do |config| + config.include ElasticsearchHelpers + + config.before(:each) do + if ENV['GROWSTUFF_ELASTICSEARCH'] == "true" + Crop.__elasticsearch__.create_index! force: true + end + end +end