Sha256: 957a4498e782391940245cebb5ef3c1ce438defbfa3855afe181576413442fbb

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 KB

Contents

require 'helper'

class TestLacquer < ActiveSupport::TestCase
  setup do
    @controller = ControllerClass.new
  end

  context "when job backend is :none" do
    should "take paths to clear cache for" do
      varnish_stub = mock('Varnish')
      Lacquer::Varnish.stubs('new').returns(varnish_stub)
      varnish_stub.expects(:purge).twice
      Lacquer.configuration.job_backend = :none
      @controller.clear_cache_for('/', '/blog/posts')
    end
  end

  context "when job backend is :delayed_job" do
    should "take paths to clear cache for" do
      Lacquer.configuration.job_backend = :delayed_job
      Delayed::Job.expects(:enqueue).twice
      @controller.clear_cache_for('/', '/blog/posts')
    end
  end

  context "when job backend is :resque" do
    should "take paths to clear cache for" do
      Lacquer.configuration.job_backend = :resque
      Resque.expects(:enqueue).twice
      @controller.clear_cache_for('/', '/blog/posts')
    end
  end

  context "when cache is enabled" do
    should "send cache control headers based on ttl" do
      Lacquer.configuration.enable_cache = true
      @controller.set_cache_ttl(10.week)
      @controller.expects(:expires_in).with(10.week, :public => true)
      @controller.send_cache_control_headers
    end
  end

  context "when cache is disabled" do
    should "do not send cache control headers" do
      Lacquer.configuration.enable_cache = false
      @controller.expects(:expires_in).never
      @controller.send_cache_control_headers
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lacquer-0.2.3 test/test_cache_utils.rb
lacquer-0.2.2 test/test_cache_utils.rb