diff --git a/lib/data_update_scripts/20200217131245_re_index_existing_articles_with_approved.rb b/lib/data_update_scripts/20200217131245_re_index_existing_articles_with_approved.rb new file mode 100644 index 000000000..3f81c9256 --- /dev/null +++ b/lib/data_update_scripts/20200217131245_re_index_existing_articles_with_approved.rb @@ -0,0 +1,7 @@ +module DataUpdateScripts + class ReIndexExistingArticlesWithApproved + def run + Article.published.find_each { |article| Article.trigger_index(article, false) } + end + end +end diff --git a/spec/lib/data_update_scripts/re_index_existing_articles_spec.rb b/spec/lib/data_update_scripts/re_index_existing_articles_spec.rb new file mode 100644 index 000000000..87c9c096a --- /dev/null +++ b/spec/lib/data_update_scripts/re_index_existing_articles_spec.rb @@ -0,0 +1,8 @@ +require "rails_helper" +require Rails.root.join("lib/data_update_scripts/20200217131245_re_index_existing_articles_with_approved.rb") + +describe DataUpdateScripts::ReIndexExistingArticlesWithApproved do + it "triggers a re-index on articles" do + expect(Article).to respond_to(:trigger_index) + end +end