Sha256: add0964a52910c2b507a2941a4af1a8fc8e856e5b1bb55771c6f85306aaa9408

Contents?: true

Size: 1.72 KB

Versions: 28

Compression:

Stored size: 1.72 KB

Contents

require 'test_helper'

module Workarea
  class SavePublishingTest < TestCase
    def test_perform_with_now
      product = create_product(active: false)

      assert(SavePublishing.new(product, activate: 'now').perform)
      assert(product.active?)
    end

    def test_perform_with_never
      product = create_product(active: false)

      assert(SavePublishing.new(product, activate: 'never').perform)
      refute(product.active?)
    end

    def test_perform_with_new_release
      product = create_product(active: false)

      publishing = SavePublishing.new(
        product,
        activate: 'new_release',
        release: { name: 'Foo' }
      )

      assert(publishing.perform)
      refute(product.active?)

      release = Release.first
      assert_equal('Foo', release.name)
      release.as_current { assert(product.reload.active?) }
    end

    def test_perform_with_existing_release
      product = create_product(active: false)
      release = create_release

      assert(SavePublishing.new(product, activate: release.id).perform)
      refute(product.active?)

      release.as_current { assert(product.reload.active?) }
    end

    def test_saving_active_segment_ids
      segment = create_segment
      product = create_product(active: false)
      release = create_release

      save = SavePublishing.new(
        product,
        activate: release.id,
        active_segment_ids: [segment.id]
      )

      assert(save.perform)

      product.reload
      refute(product.active?)
      assert_equal([], product.active_segment_ids)

      release.as_current do
        Segment.with_current(segment) { assert(product.reload.active?) }
        assert_equal([segment.id], product.active_segment_ids)
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.26 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.25 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.23 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.22 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.21 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.20 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.19 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.18 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.17 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.16 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.15 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.14 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.13 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.12 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.11 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.10 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.9 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.8 test/services/workarea/save_publishing_test.rb
workarea-core-3.5.7 test/services/workarea/save_publishing_test.rb