From e30a263bf1744d0b55d073c7d1087d0d64181d2c Mon Sep 17 00:00:00 2001
From: gbuesing <gbuesing@gmail.com>
Date: Sun, 18 May 2008 10:59:24 -0500
Subject: InstanceTag#default_time_from_options overflows to DateTime

---
 actionpack/test/template/date_helper_test.rb | 6 ++++++
 1 file changed, 6 insertions(+)

(limited to 'actionpack/test')

diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb
index ae83c7bf47..0a7b19ba96 100755
--- a/actionpack/test/template/date_helper_test.rb
+++ b/actionpack/test/template/date_helper_test.rb
@@ -1722,6 +1722,12 @@ class DateHelperTest < ActionView::TestCase
         assert_equal 2, dummy_instance_tag.send!(:default_time_from_options, :hour => 2).hour
       end
     end
+    
+    def test_instance_tag_default_time_from_options_handles_far_future_date
+      dummy_instance_tag = ActionView::Helpers::InstanceTag.new(1,2,3)
+      time = dummy_instance_tag.send!(:default_time_from_options, :year => 2050, :month => 2, :day => 10, :hour => 15, :min => 30, :sec => 45)
+      assert_equal 2050, time.year
+    end
   end
   
   protected
-- 
cgit v1.2.3


From 17d1319c480e58e28641b243da50ae5e5eab89dc Mon Sep 17 00:00:00 2001
From: Frederick Cheung <frederick.cheung@gmail.com>
Date: Sat, 17 May 2008 19:12:36 +0100
Subject: Ensure observe_field encodes value parameter. [#216 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
---
 actionpack/test/template/prototype_helper_test.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'actionpack/test')

diff --git a/actionpack/test/template/prototype_helper_test.rb b/actionpack/test/template/prototype_helper_test.rb
index 9a1079b297..5e00eadb8d 100644
--- a/actionpack/test/template/prototype_helper_test.rb
+++ b/actionpack/test/template/prototype_helper_test.rb
@@ -219,9 +219,9 @@ class PrototypeHelperTest < PrototypeHelperBaseTest
   end
   
   def test_observe_field_using_with_option
-    expected = %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/check_value', {asynchronous:true, evalScripts:true, parameters:'id=' + value})})\n//]]>\n</script>)
+    expected = %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/check_value', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(value)})})\n//]]>\n</script>)
     assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => 'id')
-    assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => "'id=' + value")
+    assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => "'id=' + encodeURIComponent(value)")
   end
   
   def test_observe_field_using_json_in_with_option
-- 
cgit v1.2.3


From 99860b72aebe0348f41e82d4710343498d89a84b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Valim?= <jose.valim@gmail.com>
Date: Fri, 16 May 2008 19:10:30 +0200
Subject: Add fragment_exist? and exist? methods to cache stores. [#203
 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
---
 actionpack/test/controller/caching_test.rb | 42 ++++++++++++++++--------------
 1 file changed, 22 insertions(+), 20 deletions(-)

(limited to 'actionpack/test')

diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index 4aacb4a78a..f9b6b87bc6 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -232,7 +232,7 @@ class ActionCacheTest < Test::Unit::TestCase
     get :index
     cached_time = content_to_cache
     assert_equal cached_time, @response.body
-    assert_cache_exists 'hostname.com/action_caching_test'
+    assert fragment_exist?('hostname.com/action_caching_test')
     reset!
 
     get :index
@@ -243,7 +243,7 @@ class ActionCacheTest < Test::Unit::TestCase
     get :destroy
     cached_time = content_to_cache
     assert_equal cached_time, @response.body
-    assert_cache_does_not_exist 'hostname.com/action_caching_test/destroy'
+    assert !fragment_exist?('hostname.com/action_caching_test/destroy')
     reset!
 
     get :destroy
@@ -254,7 +254,7 @@ class ActionCacheTest < Test::Unit::TestCase
     get :with_layout
     cached_time = content_to_cache
     assert_not_equal cached_time, @response.body
-    assert_cache_exists 'hostname.com/action_caching_test/with_layout'
+    assert fragment_exist?('hostname.com/action_caching_test/with_layout')
     reset!
 
     get :with_layout
@@ -266,14 +266,14 @@ class ActionCacheTest < Test::Unit::TestCase
   def test_action_cache_conditional_options
     @request.env['HTTP_ACCEPT'] = 'application/json'
     get :index
-    assert_cache_does_not_exist 'hostname.com/action_caching_test'
+    assert !fragment_exist?('hostname.com/action_caching_test')
   end
 
   def test_action_cache_with_custom_cache_path
     get :show
     cached_time = content_to_cache
     assert_equal cached_time, @response.body
-    assert_cache_exists 'test.host/custom/show'
+    assert fragment_exist?('test.host/custom/show')
     reset!
 
     get :show
@@ -282,11 +282,11 @@ class ActionCacheTest < Test::Unit::TestCase
 
   def test_action_cache_with_custom_cache_path_in_block
     get :edit
-    assert_cache_exists 'test.host/edit'
+    assert fragment_exist?('test.host/edit')
     reset!
 
     get :edit, :id => 1
-    assert_cache_exists 'test.host/1;edit'
+    assert fragment_exist?('test.host/1;edit')
   end
 
   def test_cache_expiration
@@ -395,18 +395,8 @@ class ActionCacheTest < Test::Unit::TestCase
       @request.host = 'hostname.com'
     end
 
-    def assert_cache_exists(path)
-      full_path = cache_path(path)
-      assert File.exist?(full_path), "#{full_path.inspect} does not exist."
-    end
-
-    def assert_cache_does_not_exist(path)
-      full_path = cache_path(path)
-      assert !File.exist?(full_path), "#{full_path.inspect} should not exist."
-    end
-
-    def cache_path(path)
-      File.join(FILE_STORE_PATH, 'views', path + '.cache')
+    def fragment_exist?(path)
+      @controller.fragment_exist?(path)
     end
 
     def read_fragment(path)
@@ -450,6 +440,19 @@ class FragmentCachingTest < Test::Unit::TestCase
     assert_nil @controller.read_fragment('name')
   end
 
+  def test_fragment_exist__with_caching_enabled
+    @store.write('views/name', 'value')
+    assert @controller.fragment_exist?('name')
+    assert !@controller.fragment_exist?('other_name')
+  end
+
+  def test_fragment_exist__with_caching_disabled
+    ActionController::Base.perform_caching = false
+    @store.write('views/name', 'value')
+    assert !@controller.fragment_exist?('name')
+    assert !@controller.fragment_exist?('other_name')
+  end
+
   def test_write_fragment__with_caching_enabled
     assert_nil @store.read('views/name')
     assert_equal 'value', @controller.write_fragment('name', 'value')
@@ -494,7 +497,6 @@ class FragmentCachingTest < Test::Unit::TestCase
     assert_equal 'generated till now -> ', buffer
   end
 
-
   def test_fragment_for
     @store.write('views/expensive', 'fragment content')
     fragment_computed = false
-- 
cgit v1.2.3


From e6f5079a48094eeba3dab9dca52b16b58ddc3634 Mon Sep 17 00:00:00 2001
From: Chris Hapgood <cch1@hapgoods.com>
Date: Fri, 16 May 2008 11:27:09 -0400
Subject: Test for assert_response for failure response without an exception.
 [#141 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
---
 actionpack/test/controller/action_pack_assertions_test.rb | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

(limited to 'actionpack/test')

diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index 1db057580b..f152b1d19c 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -131,6 +131,10 @@ class AssertResponseWithUnexpectedErrorController < ActionController::Base
   def index
     raise 'FAIL'
   end
+
+  def show
+    render :text => "Boom", :status => 500
+  end
 end
 
 module Admin
@@ -483,6 +487,16 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
   rescue Test::Unit::AssertionFailedError => e
     assert e.message.include?('FAIL')
   end
+
+  def test_assert_response_failure_response_with_no_exception
+    @controller = AssertResponseWithUnexpectedErrorController.new
+    get :show
+    assert_response :success
+    flunk 'Expected non-success response'
+  rescue Test::Unit::AssertionFailedError
+  rescue
+    flunk "assert_response failed to handle failure response with missing, but optional, exception."
+  end
 end
 
 class ActionPackHeaderTest < Test::Unit::TestCase
-- 
cgit v1.2.3


From b5c8433a6f7f869bfcd2001f8c3c4660716e873b Mon Sep 17 00:00:00 2001
From: Jeremy Kemper <jeremy@bitsweat.net>
Date: Mon, 19 May 2008 12:57:08 -0700
Subject: Ruby 1.9 compat: qualify module name within module_evaled block

---
 actionpack/test/controller/helper_test.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'actionpack/test')

diff --git a/actionpack/test/controller/helper_test.rb b/actionpack/test/controller/helper_test.rb
index 6dc77a4aaf..83e3b085e7 100644
--- a/actionpack/test/controller/helper_test.rb
+++ b/actionpack/test/controller/helper_test.rb
@@ -85,7 +85,7 @@ class HelperTest < Test::Unit::TestCase
   def test_helper_block_include
     assert_equal expected_helper_methods, missing_methods
     assert_nothing_raised {
-      @controller_class.helper { include TestHelper }
+      @controller_class.helper { include HelperTest::TestHelper }
     }
     assert [], missing_methods
   end
-- 
cgit v1.2.3


From b43309328a4a4c1f6fda6db40a4a86a3c8d643fc Mon Sep 17 00:00:00 2001
From: Jeremy Kemper <jeremy@bitsweat.net>
Date: Mon, 19 May 2008 16:01:42 -0700
Subject: Ruby 1.9 compat: ensure binary encoding for post body parsing

---
 actionpack/test/controller/test_test.rb | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

(limited to 'actionpack/test')

diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb
index ba6c7f4299..38898a1f75 100644
--- a/actionpack/test/controller/test_test.rb
+++ b/actionpack/test/controller/test_test.rb
@@ -511,16 +511,26 @@ XML
 
   FILES_DIR = File.dirname(__FILE__) + '/../fixtures/multipart'
 
+  if RUBY_VERSION < '1.9'
+    READ_BINARY = 'rb'
+    READ_PLAIN = 'r'
+  else
+    READ_BINARY = 'rb:binary'
+    READ_PLAIN = 'r:binary'
+  end
+
   def test_test_uploaded_file
     filename = 'mona_lisa.jpg'
     path = "#{FILES_DIR}/#{filename}"
     content_type = 'image/png'
+    expected = File.read(path)
+    expected.force_encoding(Encoding::BINARY) if expected.respond_to?(:force_encoding)
 
     file = ActionController::TestUploadedFile.new(path, content_type)
     assert_equal filename, file.original_filename
     assert_equal content_type, file.content_type
     assert_equal file.path, file.local_path
-    assert_equal File.read(path), file.read
+    assert_equal expected, file.read
   end
   
   def test_test_uploaded_file_with_binary
@@ -529,10 +539,10 @@ XML
     content_type = 'image/png'
     
     binary_uploaded_file = ActionController::TestUploadedFile.new(path, content_type, :binary)
-    assert_equal File.open(path, 'rb').read, binary_uploaded_file.read
+    assert_equal File.open(path, READ_BINARY).read, binary_uploaded_file.read
     
     plain_uploaded_file = ActionController::TestUploadedFile.new(path, content_type)
-    assert_equal File.open(path, 'r').read, plain_uploaded_file.read
+    assert_equal File.open(path, READ_PLAIN).read, plain_uploaded_file.read
   end
 
   def test_fixture_file_upload_with_binary
@@ -541,10 +551,10 @@ XML
     content_type = 'image/jpg'
     
     binary_file_upload = fixture_file_upload(path, content_type, :binary)
-    assert_equal File.open(path, 'rb').read, binary_file_upload.read
+    assert_equal File.open(path, READ_BINARY).read, binary_file_upload.read
     
     plain_file_upload = fixture_file_upload(path, content_type)
-    assert_equal File.open(path, 'r').read, plain_file_upload.read
+    assert_equal File.open(path, READ_PLAIN).read, plain_file_upload.read
   end
 
   def test_fixture_file_upload
-- 
cgit v1.2.3