Sha256: fe4ec8f7b0e3edc97133f520511c3fd359e7a26e4ac1247cf6caaa34b689deb2

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 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
      Lacquer.configuration.job_backend = :none
      Lacquer::VarnishInterface.expects(:send_command).twice
      @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.1 test/test_cache_utils.rb
lacquer-0.2.0 test/test_cache_utils.rb