Sha256: 85fc407e1414d00d97441cec6bf1f013169ede48dc4af3e9aa01a2bdfb9ff0f2

Contents?: true

Size: 1.63 KB

Versions: 13

Compression:

Stored size: 1.63 KB

Contents

require 'test_helper'

module Workarea
  class PublishReleaseTest < TestCase
    include TestCase::SearchIndexing

    def test_publishes_the_release
      release = create_release
      PublishRelease.new.perform(release.id)
      release.reload
      assert(release.published?)
    end

    def test_tracks_the_changes_in_the_audit_log
      release = create_release
      PublishRelease.new.perform(release.id)

      assert_equal(1, Mongoid::AuditLog::Entry.count)
      assert(Mongoid::AuditLog::Entry.first.modifier.system?)
    end

    def test_reindexes_release_schedule
      product = create_product(name: 'Foo')

      a = create_release(publish_at: 1.week.from_now)
      b = create_release(publish_at: 2.weeks.from_now)
      c = create_release(publish_at: 4.weeks.from_now)

      b.as_current { product.update!(name: 'Bar') }
      IndexProduct.perform(product)

      assert_empty(Search::ProductSearch.new(q: 'bar').results.pluck(:model))
      a.as_current { assert_empty(Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
      b.as_current { assert_equal([product], Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
      c.as_current { assert_equal([product], Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }

      Sidekiq::Callbacks.enable(IndexProduct) { PublishRelease.new.perform(b.id) }

      assert_equal([product], Search::ProductSearch.new(q: 'bar').results.pluck(:model))
      a.as_current { assert_equal([product], Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
      c.as_current { assert_equal([product], Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/workers/workarea/publish_release_test.rb
workarea-core-3.5.26 test/workers/workarea/publish_release_test.rb
workarea-core-3.5.25 test/workers/workarea/publish_release_test.rb
workarea-core-3.5.23 test/workers/workarea/publish_release_test.rb
workarea-core-3.5.22 test/workers/workarea/publish_release_test.rb
workarea-core-3.5.21 test/workers/workarea/publish_release_test.rb
workarea-core-3.5.20 test/workers/workarea/publish_release_test.rb
workarea-core-3.5.19 test/workers/workarea/publish_release_test.rb
workarea-core-3.5.18 test/workers/workarea/publish_release_test.rb
workarea-core-3.5.17 test/workers/workarea/publish_release_test.rb
workarea-core-3.5.16 test/workers/workarea/publish_release_test.rb
workarea-core-3.5.15 test/workers/workarea/publish_release_test.rb
workarea-core-3.5.14 test/workers/workarea/publish_release_test.rb