From 5a96b7efd6417b52e9d94a5d073bebc25db06e55 Mon Sep 17 00:00:00 2001 From: Shiho Takagi Date: Sun, 25 Jan 2015 15:47:40 +1100 Subject: [PATCH] adding a rake task to generate elasticsearch index --- lib/tasks/growstuff.rake | 7 +++++++ spec/support/elasticsearch_helpers.rb | 18 ------------------ 2 files changed, 7 insertions(+), 18 deletions(-) delete mode 100644 spec/support/elasticsearch_helpers.rb diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake index 656961fd3..5db6f631b 100644 --- a/lib/tasks/growstuff.rake +++ b/lib/tasks/growstuff.rake @@ -314,6 +314,13 @@ namespace :growstuff do end end end + + desc "January 2015: build Elasticsearch index" + task :elasticsearch_create_index => :environment do + Crop.__elasticsearch__.create_index! force: true + Crop.import + end + end # end oneoff section end diff --git a/spec/support/elasticsearch_helpers.rb b/spec/support/elasticsearch_helpers.rb deleted file mode 100644 index 0e80ea321..000000000 --- a/spec/support/elasticsearch_helpers.rb +++ /dev/null @@ -1,18 +0,0 @@ -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 \ No newline at end of file