Sha256: 6185450d91b66e2ba42eb13f59e19b0ae3c7466287253a75479deebe678a4730

Contents?: true

Size: 1.86 KB

Versions: 34

Compression:

Stored size: 1.86 KB

Contents

require 'test_helper'

module Workarea
  class VerifyScheduledReleasesTest < TestCase
    setup :set_sidekiq
    teardown :reset_sidekiq

    def set_sidekiq
      Sidekiq::Testing.disable!

      @scheduled_set = Sidekiq::ScheduledSet.new
      @scheduled_set.clear
    end

    def reset_sidekiq
      Sidekiq::Testing.inline!
    end

    def test_rescheduling_publish
      release = create_release(publish_at: Time.current + 1.hour)

      assert(release.publish_job_id.present?)
      original_job_id = release.publish_job_id
      @scheduled_set.clear

      VerifyScheduledReleases.new.perform
      release.reload

      refute_equal(original_job_id, release.publish_job_id)
      assert_equal(1, @scheduled_set.size)
    end

    def test_skipping_publish_dates_in_the_past
      release = create_release
      release.update_attribute(:publish_at, Time.current - 1.hour)
      release.update_attribute(:publish_job_id, '123')

      VerifyScheduledReleases.new.perform
      release.reload

      assert_equal('123', release.publish_job_id)
      assert_equal(0, @scheduled_set.size)
    end

    def test_rescheduling_undo
      release = create_release(published_at: Time.current, undo_at: Time.current + 1.hour)

      assert(release.undo_job_id.present?)
      original_job_id = release.undo_job_id
      @scheduled_set.clear

      VerifyScheduledReleases.new.perform
      release.reload

      refute_equal(original_job_id, release.undo_job_id)
      assert_equal(1, @scheduled_set.size)
    end

    def test_skipping_undo_dates_in_the_past
      release = create_release(published_at: Time.current)
      release.update_attribute(:undo_at, Time.current - 1.hour)
      release.update_attribute(:undo_job_id, '123')

      VerifyScheduledReleases.new.perform
      release.reload

      assert_equal('123', release.undo_job_id)
      assert_equal(0, @scheduled_set.size)
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-core-3.4.45 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.44 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.43 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.42 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.41 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.40 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.39 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.38 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.37 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.36 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.35 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.34 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.33 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.32 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.31 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.30 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.29 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.28 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.27 test/workers/workarea/verify_scheduled_releases_test.rb
workarea-core-3.4.26 test/workers/workarea/verify_scheduled_releases_test.rb