Sha256: 87b1559eccf76cc47a551238534ad788c9766fdb84dffc0efae2580ab3eb1996

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

require 'test_helper'

module Workarea
  class IndexContentTest < Workarea::TestCase
    include TestCase::SearchIndexing

    def test_excluding_content
      Search::Storefront.reset_indexes!

      content = [
        Content.for(create_page),
        Content.for('home_page'),
        Content.for(create_category),
        Content.for(create_search_customization)
      ]

      content.each { |c| IndexContent.perform(c) }

      assert_equal(1, Search::Storefront.count)

      results = Search::Storefront.search('*')['hits']['hits']
      assert_includes(results.first['_source']['id'], content.first.id.to_s)
    end

    def test_removing_content
      content = create_content(contentable: create_page)

      IndexContent.new.perform(content.id)
      assert_equal(Search::Storefront.count, 1)

      content.destroy!
      IndexContent.new.perform(content.id)
      assert(Search::Storefront.count.zero?)
    end

    def test_saving_from_block_changes
      content = Content.for(create_page)

      assert_equal(0, Search::Storefront.count)

      Sidekiq::Callbacks.enable(IndexContent) do
        content.blocks.create!(
          type: 'html',
          data: { html: '<p>foo bar!</p>' }
        )
      end

      assert_equal(1, Search::Storefront.count)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-content_search-1.1.0 test/workers/workarea/index_content_test.rb
workarea-content_search-1.0.9 test/workers/workarea/index_content_test.rb
workarea-content_search-1.0.8 test/workers/workarea/index_content_test.rb