Sha256: 465c51af71a58b1a620b7574a5c90ec06e363de0792a6f9707258d5c232b7f3b

Contents?: true

Size: 984 Bytes

Versions: 3

Compression:

Stored size: 984 Bytes

Contents

require "test_helper"

class QueueTest < ActiveSupport::TestCase
  include ActiveJob::TestHelper
  self.use_transactional_tests = true
  teardown :clear_cache

  test "uses the default background queue by default" do
    mock = Minitest::Mock.new
    category = categories(:baseball)

    Thermos.fill(key: "key", model: Category) { |id| mock.call(id) }

    mock.expect(:call, 1, [category.id])
    assert_performed_with(job: Thermos::RebuildCacheJob, queue: "default") do
      category.update!(name: "foo")
    end
    mock.verify
  end

  test "can specify a preferred queue name for the cache filling" do
    mock = Minitest::Mock.new
    category = categories(:baseball)

    Thermos.fill(key: "key", model: Category, queue: "low_priority") do |id|
      mock.call(id)
    end

    mock.expect(:call, 1, [category.id])
    assert_performed_with(
      job: Thermos::RebuildCacheJob,
      queue: "low_priority",
    ) { category.update!(name: "foo") }
    mock.verify
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thermos-1.0.2 test/queue_test.rb
thermos-1.0.1 test/queue_test.rb
thermos-1.0.0 test/queue_test.rb