From 5c9c30ac65d25bd5a83d773739c2cd8fdd6da4d3 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 21 Apr 2010 01:33:48 -0300 Subject: url_for now works with HashWithIndifferentAccess ht jay [#4391 state:committed] Signed-off-by: Jeremy Kemper --- actionpack/test/template/url_helper_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 4474949749..314ed91fdd 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -421,6 +421,11 @@ class UrlHelperControllerTest < ActionController::TestCase render :inline => "<%= url_for :controller => 'url_helper_controller_test/url_helper', :action => 'show_url_for' %>" end + def show_overriden_url_for + params = { :controller => 'c', :action => 'a' } + render :inline => "<%= url_for params.merge(:controller => 'url_helper_controller_test/url_helper', :action => 'show_url_for') %>" + end + def show_named_route render :inline => "<%= show_named_route_#{params[:kind]} %>" end @@ -439,6 +444,11 @@ class UrlHelperControllerTest < ActionController::TestCase assert_equal '/url_helper_controller_test/url_helper/show_url_for', @response.body end + def test_overriden_url_for_shows_only_path + get :show_overriden_url_for + assert_equal '/url_helper_controller_test/url_helper/show_url_for', @response.body + end + def test_named_route_url_shows_host_and_path get :show_named_route, :kind => 'url' assert_equal 'http://test.host/url_helper_controller_test/url_helper/show_named_route', -- cgit v1.2.3 From a8330c2006e90a6da8f621fdaf1156fa63b4049a Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 21 Apr 2010 21:30:23 -0300 Subject: params already has a setted controller and action here Signed-off-by: Jeremy Kemper --- actionpack/test/template/url_helper_test.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'actionpack/test') diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 314ed91fdd..5120870f50 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -422,7 +422,6 @@ class UrlHelperControllerTest < ActionController::TestCase end def show_overriden_url_for - params = { :controller => 'c', :action => 'a' } render :inline => "<%= url_for params.merge(:controller => 'url_helper_controller_test/url_helper', :action => 'show_url_for') %>" end -- cgit v1.2.3 From 4163ccec2343ee66e2488f067eab2a15260e1219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 22 Apr 2010 12:00:13 +0200 Subject: Clean up the config object in ActionPack. Create config_accessor which just delegates to the config object, reducing the number of deprecations and add specific tests. --- actionpack/test/template/form_tag_helper_test.rb | 3 --- 1 file changed, 3 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index ef612b879b..8756bd310f 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -3,9 +3,6 @@ require 'abstract_unit' class FormTagHelperTest < ActionView::TestCase tests ActionView::Helpers::FormTagHelper - # include ActiveSupport::Configurable - # DEFAULT_CONFIG = ActionView::DEFAULT_CONFIG - def setup super @controller = BasicController.new -- cgit v1.2.3 From 81fb742488e696ee7a7a8b1a620bc93deb1fad77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 22 Apr 2010 12:12:38 +0200 Subject: Always downstream given options in :json, :xml and :js renderers and add tests for it. --- actionpack/test/controller/render_json_test.rb | 18 ++++++++++++++++++ actionpack/test/controller/render_xml_test.rb | 24 +++++++++++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/render_json_test.rb b/actionpack/test/controller/render_json_test.rb index 2580ada88b..5958b18d80 100644 --- a/actionpack/test/controller/render_json_test.rb +++ b/actionpack/test/controller/render_json_test.rb @@ -3,6 +3,14 @@ require 'controller/fake_models' require 'pathname' class RenderJsonTest < ActionController::TestCase + class JsonRenderable + def as_json(options={}) + hash = { :a => :b, :c => :d, :e => :f } + hash.except!(*options[:except]) if options[:except] + hash + end + end + class TestController < ActionController::Base protect_from_forgery @@ -37,6 +45,10 @@ class RenderJsonTest < ActionController::TestCase def render_json_with_render_to_string render :json => {:hello => render_to_string(:partial => 'partial')} end + + def render_json_with_extra_options + render :json => JsonRenderable.new, :except => [:c, :e] + end end tests TestController @@ -91,4 +103,10 @@ class RenderJsonTest < ActionController::TestCase assert_equal '{"hello":"partial html"}', @response.body assert_equal 'application/json', @response.content_type end + + def test_render_json_forwards_extra_options + get :render_json_with_extra_options + assert_equal '{"a":"b"}', @response.body + assert_equal 'application/json', @response.content_type + end end diff --git a/actionpack/test/controller/render_xml_test.rb b/actionpack/test/controller/render_xml_test.rb index 4da6c954cf..518842c34c 100644 --- a/actionpack/test/controller/render_xml_test.rb +++ b/actionpack/test/controller/render_xml_test.rb @@ -3,6 +3,13 @@ require 'controller/fake_models' require 'pathname' class RenderXmlTest < ActionController::TestCase + class XmlRenderable + def to_xml(options) + options[:root] ||= "i-am-xml" + "<#{options[:root]}/>" + end + end + class TestController < ActionController::Base protect_from_forgery @@ -20,13 +27,7 @@ class RenderXmlTest < ActionController::TestCase end def render_with_to_xml - to_xmlable = Class.new do - def to_xml - "" - end - end.new - - render :xml => to_xmlable + render :xml => XmlRenderable.new end def formatted_xml_erb @@ -35,6 +36,10 @@ class RenderXmlTest < ActionController::TestCase def render_xml_with_custom_content_type render :xml => "", :content_type => "application/atomsvc+xml" end + + def render_xml_with_custom_options + render :xml => XmlRenderable.new, :root => "i-am-THE-xml" + end end tests TestController @@ -58,6 +63,11 @@ class RenderXmlTest < ActionController::TestCase assert_equal "", @response.body end + def test_rendering_xml_should_call_to_xml_with_extra_options + get :render_with_to_xml + assert_equal "", @response.body + end + def test_rendering_with_object_location_should_set_header_with_url_for with_routing do |set| set.draw do |map| -- cgit v1.2.3 From 275e839b8dfa3cf2bdedf1b31302dec20ac96a46 Mon Sep 17 00:00:00 2001 From: J Smith Date: Wed, 21 Apr 2010 21:37:51 -0400 Subject: Ensure that url_for uses symbolized keys in the controller. [#4391] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- actionpack/test/controller/url_for_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb index fc7773dffe..501f928e05 100644 --- a/actionpack/test/controller/url_for_test.rb +++ b/actionpack/test/controller/url_for_test.rb @@ -257,6 +257,16 @@ module AbstractController assert_equal second_class.default_url_options[:host], second_host end + def test_with_stringified_keys + assert_equal("/c/a", W.new.url_for('controller' => 'c', 'action' => 'a', 'only_path' => true)) + assert_equal("/c", W.new.url_for('controller' => 'c', 'only_path' => true)) + end + + def test_with_hash_with_indifferent_access + assert_equal("/c/a", W.new.url_for(HashWithIndifferentAccess.new('controller' => 'c', 'action' => 'a', 'only_path' => true))) + assert_equal("/c", W.new.url_for(HashWithIndifferentAccess.new('controller' => 'c', 'only_path' => true))) + end + private def extract_params(url) url.split('?', 2).last.split('&').sort -- cgit v1.2.3 From 920df0a4758d003dc284c13e439e0b9f60a6e6f0 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 22 Apr 2010 12:33:54 -0300 Subject: Make ActionDispatch url_for use HWIA symbolize_keys Signed-off-by: Jeremy Kemper --- actionpack/test/controller/url_for_test.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb index 501f928e05..907acf9573 100644 --- a/actionpack/test/controller/url_for_test.rb +++ b/actionpack/test/controller/url_for_test.rb @@ -258,13 +258,17 @@ module AbstractController end def test_with_stringified_keys - assert_equal("/c/a", W.new.url_for('controller' => 'c', 'action' => 'a', 'only_path' => true)) assert_equal("/c", W.new.url_for('controller' => 'c', 'only_path' => true)) + assert_equal("/c/a", W.new.url_for('controller' => 'c', 'action' => 'a', 'only_path' => true)) end def test_with_hash_with_indifferent_access - assert_equal("/c/a", W.new.url_for(HashWithIndifferentAccess.new('controller' => 'c', 'action' => 'a', 'only_path' => true))) + W.default_url_options[:controller] = 'd' + W.default_url_options[:only_path] = false assert_equal("/c", W.new.url_for(HashWithIndifferentAccess.new('controller' => 'c', 'only_path' => true))) + + W.default_url_options[:action] = 'b' + assert_equal("/c/a", W.new.url_for(HashWithIndifferentAccess.new('controller' => 'c', 'action' => 'a', 'only_path' => true))) end private @@ -273,4 +277,4 @@ module AbstractController end end end -end \ No newline at end of file +end -- cgit v1.2.3 From aaaa1782b44c620cecb97238534a2bd2be5d365a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 24 Apr 2010 11:48:47 +0200 Subject: =?UTF-8?q?Fix=20render=20:xml=20test=20(ht=20Simo=20Niemel=C3=A4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- actionpack/test/controller/render_xml_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/render_xml_test.rb b/actionpack/test/controller/render_xml_test.rb index 518842c34c..4bf867fa41 100644 --- a/actionpack/test/controller/render_xml_test.rb +++ b/actionpack/test/controller/render_xml_test.rb @@ -64,8 +64,8 @@ class RenderXmlTest < ActionController::TestCase end def test_rendering_xml_should_call_to_xml_with_extra_options - get :render_with_to_xml - assert_equal "", @response.body + get :render_xml_with_custom_options + assert_equal "", @response.body end def test_rendering_with_object_location_should_set_header_with_url_for -- cgit v1.2.3 From 72a3e4b77b0e6e249a534d41ae48acdedd2098cc Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 24 Apr 2010 14:57:49 -0700 Subject: Rename fieldWithErrors style to field_with_errors. Remove unused alert style. --- actionpack/test/template/active_model_helper_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/template/active_model_helper_test.rb b/actionpack/test/template/active_model_helper_test.rb index 8deeb78eab..b1705072c2 100644 --- a/actionpack/test/template/active_model_helper_test.rb +++ b/actionpack/test/template/active_model_helper_test.rb @@ -27,14 +27,14 @@ class ActiveModelHelperTest < ActionView::TestCase def test_text_area_with_errors assert_dom_equal( - %(
), + %(
), text_area("post", "body") ) end def test_text_field_with_errors assert_dom_equal( - %(
), + %(
), text_field("post", "author_name") ) end @@ -42,11 +42,11 @@ class ActiveModelHelperTest < ActionView::TestCase def test_field_error_proc old_proc = ActionView::Base.field_error_proc ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| - %(
#{html_tag} #{[instance.error_message].join(', ')}
).html_safe + %(
#{html_tag} #{[instance.error_message].join(', ')}
).html_safe end assert_dom_equal( - %(
can't be empty
), + %(
can't be empty
), text_field("post", "author_name") ) ensure -- cgit v1.2.3 From ed0ca5db9ea247ceae67f22a750cbd49006f35ed Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Sat, 24 Apr 2010 19:17:30 -0300 Subject: Add a test for assert_recognizes on ActionDispatch::IntegrationTest [#4390 state:committed] Signed-off-by: Jeremy Kemper --- actionpack/test/abstract_unit.rb | 8 +++++++- actionpack/test/dispatch/routing_test.rb | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'actionpack/test') diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index acf887ee4a..f3ff258016 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -143,6 +143,12 @@ class BasicController end end +class ActionDispatch::IntegrationTest < ActiveSupport::TestCase + setup do + @routes = SharedTestRoutes + end +end + class ActionController::IntegrationTest < ActiveSupport::TestCase def self.build_app(routes = nil) RoutedRackApp.new(routes || ActionDispatch::Routing::RouteSet.new) do |middleware| @@ -275,4 +281,4 @@ module ActionController class Base include SharedTestRoutes.url_helpers end -end \ No newline at end of file +end diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 5bca476b27..f67e403330 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -1000,6 +1000,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end end + def test_assert_recognizes_account_overview + with_test_routes do + assert_recognizes({:controller => "account", :action => "overview"}, "/account/overview") + end + end + private def with_test_routes yield -- cgit v1.2.3 From 403752e28993493d87ae4e69f9aca1858eb133f7 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 24 Apr 2010 18:35:12 -0700 Subject: Explicit source encoding --- actionpack/test/template/text_helper_test.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/test') diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb index 9962b7af3f..8b6c107a21 100644 --- a/actionpack/test/template/text_helper_test.rb +++ b/actionpack/test/template/text_helper_test.rb @@ -1,3 +1,4 @@ +# encoding: us-ascii require 'abstract_unit' require 'testing_sandbox' begin -- cgit v1.2.3 From df886c4c89f3b8a95ef2456d6893393376b330a9 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 24 Apr 2010 18:52:51 -0700 Subject: Missed commit: explicit source encoding --- actionpack/test/controller/assert_select_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/assert_select_test.rb b/actionpack/test/controller/assert_select_test.rb index cb3e848dfa..4ef6fa4000 100644 --- a/actionpack/test/controller/assert_select_test.rb +++ b/actionpack/test/controller/assert_select_test.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 #-- # Copyright (c) 2006 Assaf Arkin (http://labnotes.org) # Under MIT and/or CC By license. @@ -347,7 +348,6 @@ class AssertSelectTest < ActionController::TestCase assert_select str, :text => "\343\203\201\343\202\261\343\203\203\343\203\210" assert_select str, "\343\203\201\343\202\261\343\203\203\343\203\210" if str.respond_to?(:force_encoding) - str.force_encoding(Encoding::UTF_8) assert_select str, /\343\203\201..\343\203\210/u assert_raise(Assertion) { assert_select str, /\343\203\201.\343\203\210/u } else -- cgit v1.2.3 From 490a3335d56c124c8113aac0b63ad367f81bb450 Mon Sep 17 00:00:00 2001 From: Cezary Baginski Date: Sun, 25 Apr 2010 19:48:40 +0200 Subject: Action Pack: fix tests with -K*, work around Ruby 1.9.1 constant lookup. [#4473 state:committed] Signed-off-by: Jeremy Kemper --- actionpack/test/controller/send_file_test.rb | 4 ++-- actionpack/test/dispatch/routing_test.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb index 30c9a65b7c..36b8055810 100644 --- a/actionpack/test/controller/send_file_test.rb +++ b/actionpack/test/controller/send_file_test.rb @@ -25,7 +25,7 @@ class SendFileController < ActionController::Base end def multibyte_text_data - send_data("Кирилица\n祝您好運", options) + send_data("Кирилица\n祝您好運.", options) end end @@ -128,7 +128,7 @@ class SendFileTest < ActionController::TestCase assert_equal 'image/png', @controller.content_type end - + def test_send_file_headers_with_bad_symbol options = { diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index f67e403330..b508996467 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -237,8 +237,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest AltRoutes = ActionDispatch::Routing::RouteSet.new(AltRequest) AltRoutes.draw do - get "/" => XHeader.new, :constraints => {:x_header => /HEADER/} - get "/" => AltApp.new + get "/" => TestRoutingMapper::TestAltApp::XHeader.new, :constraints => {:x_header => /HEADER/} + get "/" => TestRoutingMapper::TestAltApp::AltApp.new end def app -- cgit v1.2.3 From 53c13f1acaa2eb05e7f418b53f6156a4f5a773e0 Mon Sep 17 00:00:00 2001 From: Anil Wadghule Date: Mon, 26 Apr 2010 20:55:07 +0530 Subject: Use Config::CONFIG['host_os'] instead of RUBY_PLATFORM [#4477 state:resolved] Signed-off-by: Jeremy Kemper --- actionpack/test/controller/layout_test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb index e1c1128753..48be7571ea 100644 --- a/actionpack/test/controller/layout_test.rb +++ b/actionpack/test/controller/layout_test.rb @@ -1,4 +1,5 @@ require 'abstract_unit' +require 'rbconfig' # The view_paths array must be set on Base and not LayoutTest so that LayoutTest's inherited # method has access to the view_paths array when looking for a layout to automatically assign. @@ -209,7 +210,7 @@ class LayoutStatusIsRenderedTest < ActionController::TestCase end end -unless RUBY_PLATFORM =~ /mswin|mingw/ +unless Config::CONFIG['host_os'] =~ /mswin|mingw/ class LayoutSymlinkedTest < LayoutTest layout "symlinked/symlinked_layout" end -- cgit v1.2.3