Sha256: e959f08d45568ef71df286e26d119979492ec533df9db634705f907bee61c886

Contents?: true

Size: 825 Bytes

Versions: 3

Compression:

Stored size: 825 Bytes

Contents

require 'test_helper'

class TestCaching < Test::Unit::TestCase
  def setup
    @client = MockMogileFsClient.new
  end

  def test_expires_with_int
    @client.expects(:get_file_data).with("/assets/image.png").returns("")

    app_with(
      :path    => %r{^/assets/*},
      :client  => @client,
      :expires => 300
    )

    get '/assets/image.png'
    assert_status 200
    assert_cache_control "max-age=300, public"
  end

  def test_expires_with_lambda
    @client.expects(:get_file_data).with("/assets/image.jpg").returns("")
  
    app_with(
      :path    => %r{^/assets/*},
      :client  => @client,
      :expires => lambda { |path, ext, mime|
        mime == "image/jpeg" ? 600 : 300
      }
    )
  
    get '/assets/image.jpg'
    assert_status 200
    assert_cache_control "max-age=600, public"
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rack-mogilefs-0.3.2 test/caching_test.rb
rack-mogilefs-0.3.1 test/caching_test.rb
rack-mogilefs-0.3.0 test/caching_test.rb