Sha256: 54719459c10db945c442eea843bee1a6341bea68ddf521f68c2313e89a6a6f62

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

require 'test_helper'
require 'camping'

Camping.goes :Cookies

module Cookies::Controllers
  class One
    def get
      @cookies.simple = '42'
      @cookies.set :complex, '43'
      @cookies.set :past, 'past', :expires => Time.now - 5
      render :show
    end
  end

  class Two
    def get
      render :show
    end
  end

  class Old
    def get
      @cookies.simple = '42'
      @cookies.complex = { :value => '43' }
      @cookies.past = { :value => 'past', :expires => Time.now - 5 }
      @cookies.past.class.name
    end
  end
end

module Cookies::Views
  def show
    @cookies.values_at('simple', 'complex', 'past').inspect
  end
end

class Cookies::Test < TestCase
  def test_cookies
    get '/one'
    assert_body '["42", "43", "past"]'

    get '/two'
    assert_body '["42", "43", nil]'
  end

  def test_backward_compatible
    get '/old'
    assert_body 'Hash'

    get '/two'
    assert_body '["42", "43", nil]'
  end

  def test_path
    get '/one', {}, 'SCRIPT_NAME' => '/mnt'
    assert_body '["42", "43", "past"]'
    assert_equal 3, last_response.headers["Set-Cookie"].scan('path=/mnt/').size
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
camping-2.1.532 test/app_cookies.rb
camping-2.1.531 test/app_cookies.rb
camping-2.1.523 test/app_cookies.rb
camping-2.1.467 test/app_cookies.rb