Sha256: a787b35e08cf01d5927c0f04db821c70ba270b95a5d044e612e52c81ceb096e0

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

require "test_helper"

class CacheKeeper::CachedMethod::RefreshableTest < ActiveSupport::TestCase
  include ActiveJob::TestHelper

  test "#refresh_later enqueues a refresh job" do
    recording = Recording.create(number: 5)
    cached_method = CacheKeeper.manager.cached_methods.first

    assert_enqueued_with(job: CacheKeeper::RefreshJob) do
      cached_method.refresh_later recording
    end
  end

  test "#autorefresh enqueues a refresh job if it's stale" do
    with_clean_caching do
      recording = Recording.create(number: 5)
      cached_method = CacheKeeper.manager.cached_methods.first

      assert_enqueued_with(job: CacheKeeper::RefreshJob) do
        cached_method.autorefresh recording
      end
    end
  end

  test "#autorefresh doesn't enqueue a refresh job if it's fresh" do
    with_clean_caching do
      recording = Recording.create(number: 5)
      cached_method = CacheKeeper.manager.cached_methods.first
      cached_method.call(recording)

      assert_no_enqueued_jobs do
        cached_method.autorefresh recording
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cache_keeper-0.6.1 test/models/cached_method/refreshable_test.rb
cache_keeper-0.6.0 test/models/cached_method/refreshable_test.rb
cache_keeper-0.5.1 test/models/cached_method/refreshable_test.rb
cache_keeper-0.5.0 test/models/cached_method/refreshable_test.rb