aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/content_type_test.rb20
-rw-r--r--actionpack/test/controller/polymorphic_routes_test.rb22
-rw-r--r--actionpack/test/controller/rack_test.rb6
3 files changed, 43 insertions, 5 deletions
diff --git a/actionpack/test/controller/content_type_test.rb b/actionpack/test/controller/content_type_test.rb
index e1bc46bb56..ae71d62e11 100644
--- a/actionpack/test/controller/content_type_test.rb
+++ b/actionpack/test/controller/content_type_test.rb
@@ -19,6 +19,11 @@ class ContentTypeController < ActionController::Base
render :text => "hello world!"
end
+ def render_nil_charset_from_body
+ response.charset = nil
+ render :text => "hello world!"
+ end
+
def render_default_for_rhtml
end
@@ -85,8 +90,23 @@ class ContentTypeTest < Test::Unit::TestCase
def test_charset_from_body
get :render_charset_from_body
+ assert_equal Mime::HTML, @response.content_type
assert_equal "utf-16", @response.charset
+ end
+
+ def test_nil_charset_from_body
+ get :render_nil_charset_from_body
assert_equal Mime::HTML, @response.content_type
+ assert_equal "utf-8", @response.charset, @response.headers.inspect
+ end
+
+ def test_nil_default_for_rhtml
+ ContentTypeController.default_charset = nil
+ get :render_default_for_rhtml
+ assert_equal Mime::HTML, @response.content_type
+ assert_nil @response.charset, @response.headers.inspect
+ ensure
+ ContentTypeController.default_charset = "utf-8"
end
def test_default_for_rhtml
diff --git a/actionpack/test/controller/polymorphic_routes_test.rb b/actionpack/test/controller/polymorphic_routes_test.rb
index 3f52526f08..6ddf2826cd 100644
--- a/actionpack/test/controller/polymorphic_routes_test.rb
+++ b/actionpack/test/controller/polymorphic_routes_test.rb
@@ -60,6 +60,18 @@ uses_mocha 'polymorphic URL helpers' do
edit_polymorphic_url(@article)
end
+ def test_url_helper_prefixed_with_edit_with_url_options
+ @article.save
+ expects(:edit_article_url).with(@article, :param1 => '10')
+ edit_polymorphic_url(@article, :param1 => '10')
+ end
+
+ def test_url_helper_with_url_options
+ @article.save
+ expects(:article_url).with(@article, :param1 => '10')
+ polymorphic_url(@article, :param1 => '10')
+ end
+
def test_formatted_url_helper
expects(:formatted_article_url).with(@article, :pdf)
formatted_polymorphic_url([@article, :pdf])
@@ -67,10 +79,16 @@ uses_mocha 'polymorphic URL helpers' do
def test_format_option
@article.save
- expects(:article_url).with(@article, :pdf)
+ expects(:formatted_article_url).with(@article, :pdf)
polymorphic_url(@article, :format => :pdf)
end
+ def test_format_option_with_url_options
+ @article.save
+ expects(:formatted_article_url).with(@article, :pdf, :param1 => '10')
+ polymorphic_url(@article, :format => :pdf, :param1 => '10')
+ end
+
def test_id_and_format_option
@article.save
expects(:article_url).with(:id => @article, :format => :pdf)
@@ -147,7 +165,7 @@ uses_mocha 'polymorphic URL helpers' do
def test_nesting_with_array_containing_singleton_resource_and_format_option
@tag = Tag.new
@tag.save
- expects(:article_response_tag_url).with(@article, @tag, :pdf)
+ expects(:formatted_article_response_tag_url).with(@article, @tag, :pdf)
polymorphic_url([@article, :response, @tag], :format => :pdf)
end
diff --git a/actionpack/test/controller/rack_test.rb b/actionpack/test/controller/rack_test.rb
index 30a1144aad..d5e56b9584 100644
--- a/actionpack/test/controller/rack_test.rb
+++ b/actionpack/test/controller/rack_test.rb
@@ -241,7 +241,7 @@ class RackResponseTest < BaseRackTest
status, headers, body = @response.out(@output)
assert_equal "200 OK", status
assert_equal({
- "Content-Type" => "text/html",
+ "Content-Type" => "text/html; charset=utf-8",
"Cache-Control" => "private, max-age=0, must-revalidate",
"ETag" => '"65a8e27d8879283831b664bd8b7f0ad4"',
"Set-Cookie" => [],
@@ -261,7 +261,7 @@ class RackResponseTest < BaseRackTest
status, headers, body = @response.out(@output)
assert_equal "200 OK", status
- assert_equal({"Content-Type" => "text/html", "Cache-Control" => "no-cache", "Set-Cookie" => []}, headers)
+ assert_equal({"Content-Type" => "text/html; charset=utf-8", "Cache-Control" => "no-cache", "Set-Cookie" => []}, headers)
parts = []
body.each { |part| parts << part }
@@ -278,7 +278,7 @@ class RackResponseTest < BaseRackTest
status, headers, body = @response.out(@output)
assert_equal "200 OK", status
assert_equal({
- "Content-Type" => "text/html",
+ "Content-Type" => "text/html; charset=utf-8",
"Cache-Control" => "private, max-age=0, must-revalidate",
"ETag" => '"65a8e27d8879283831b664bd8b7f0ad4"',
"Set-Cookie" => ["name=Josh; path="],