Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 1065

Show
Ignore:
Timestamp:
04/02/05 08:54:25 (3 years ago)
Author:
david
Message:

Added assert_no_cookie and fixed assert_cookie_equal to deal with non-existing cookies #979 [bitsweat]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r1061 r1065  
    11*SVN* 
     2 
     3* Added assert_no_cookie and fixed assert_cookie_equal to deal with non-existing cookies #979 [bitsweat] 
    24 
    35* Fixed :overwrite_param so it doesn't delete but reject elements from @request.parameters #982 [raphinou@yahoo.com] 
  • trunk/actionpack/lib/action_controller/assertions/action_pack_assertions.rb

    r948 r1065  
    6464      # -- cookie assertions --------------------------------------------------- 
    6565 
     66      def assert_no_cookie(key = nil, message = nil) 
     67        response = acquire_assertion_target 
     68        actual = response.cookies[key] 
     69        msg = build_message(message, "<?> not expected in cookies['?']", actual, key) 
     70        assert_block(msg) { actual.nil? or actual.empty? } 
     71      end 
     72       
    6673      def assert_cookie_equal(expected = nil, key = nil, message = nil) 
    6774        response = acquire_assertion_target 
    68         msg = build_message(message, "<?> expected in cookies['?'] but was <?>", expected, key, response.cookies[key.to_s].first) 
    69         assert_block(msg) { expected == response.cookies[key.to_s].first } 
     75        actual = response.cookies[key] 
     76        actual = actual.first if actual 
     77        msg = build_message(message, "<?> expected in cookies['?'] but was <?>", expected, key, actual) 
     78        assert_block(msg) { expected == actual } 
    7079      end 
    7180       
  • trunk/actionpack/test/controller/cookie_test.rb

    r617 r1065  
    2626      cookies["user_name"] = { "value" => "david", "expires" => Time.local(2005, 10, 10) } 
    2727      cookies["login"]     = "XJ-122" 
     28      render_text "hello world" 
     29    end 
     30 
     31    def access_frozen_cookies 
     32      @cookies["will"] = "work" 
    2833      render_text "hello world" 
    2934    end 
     
    6469  end 
    6570 
     71  def test_setting_test_cookie 
     72    @request.action = "access_frozen_cookies" 
     73    assert_nothing_raised { process_request } 
     74  end 
     75 
    6676  private 
    6777    def process_request