diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-11-20 08:52:48 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-11-20 08:52:48 +0100 |
commit | 206c5643aae40b0884d42fdb8caeb3f763936fa9 (patch) | |
tree | 608f5cc7daab7b58b3d159429c595303e7e1c7d4 /actionpack/test/controller | |
parent | fb1eebac940d0648d1640d20a24f085d901d6f30 (diff) | |
parent | 20a346170cf3922d16e265487cfb1abcc85383c1 (diff) | |
download | rails-206c5643aae40b0884d42fdb8caeb3f763936fa9.tar.gz rails-206c5643aae40b0884d42fdb8caeb3f763936fa9.tar.bz2 rails-206c5643aae40b0884d42fdb8caeb3f763936fa9.zip |
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/components_test.rb | 152 | ||||
-rw-r--r-- | actionpack/test/controller/polymorphic_routes_test.rb | 6 | ||||
-rw-r--r-- | actionpack/test/controller/render_test.rb | 14 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 12 |
4 files changed, 29 insertions, 155 deletions
diff --git a/actionpack/test/controller/components_test.rb b/actionpack/test/controller/components_test.rb deleted file mode 100644 index e7b17aa34e..0000000000 --- a/actionpack/test/controller/components_test.rb +++ /dev/null @@ -1,152 +0,0 @@ -require 'abstract_unit' - -class CallerController < ActionController::Base - def calling_from_controller - render_component(:controller => "callee", :action => "being_called") - end - - def calling_from_controller_with_params - render_component(:controller => "callee", :action => "being_called", :params => { "name" => "David" }) - end - - def calling_from_controller_with_different_status_code - render_component(:controller => "callee", :action => "blowing_up") - end - - def calling_from_template - render :inline => "Ring, ring: <%= render_component(:controller => 'callee', :action => 'being_called') %>" - end - - def internal_caller - render :inline => "Are you there? <%= render_component(:action => 'internal_callee') %>" - end - - def internal_callee - render :text => "Yes, ma'am" - end - - def set_flash - render_component(:controller => "callee", :action => "set_flash") - end - - def use_flash - render_component(:controller => "callee", :action => "use_flash") - end - - def calling_redirected - render_component(:controller => "callee", :action => "redirected") - end - - def calling_redirected_as_string - render :inline => "<%= render_component(:controller => 'callee', :action => 'redirected') %>" - end - - def rescue_action(e) raise end -end - -class CalleeController < ActionController::Base - def being_called - render :text => "#{params[:name] || "Lady"} of the House, speaking" - end - - def blowing_up - render :text => "It's game over, man, just game over, man!", :status => 500 - end - - def set_flash - flash[:notice] = 'My stoney baby' - render :text => 'flash is set' - end - - def use_flash - render :text => flash[:notice] || 'no flash' - end - - def redirected - redirect_to :controller => "callee", :action => "being_called" - end - - def rescue_action(e) raise end -end - -class ComponentsTest < ActionController::TestCase - tests CallerController - - def test_calling_from_controller - assert_deprecated do - get :calling_from_controller - assert_equal "Lady of the House, speaking", @response.body - end - end - - def test_calling_from_controller_with_params - assert_deprecated do - get :calling_from_controller_with_params - assert_equal "David of the House, speaking", @response.body - end - end - - def test_calling_from_controller_with_different_status_code - assert_deprecated do - get :calling_from_controller_with_different_status_code - assert_equal 500, @response.response_code - end - end - - def test_calling_from_template - assert_deprecated do - get :calling_from_template - assert_equal "Ring, ring: Lady of the House, speaking", @response.body - end - end - - def test_etag_is_set_for_parent_template_when_calling_from_template - assert_deprecated do - get :calling_from_template - expected_etag = etag_for("Ring, ring: Lady of the House, speaking") - assert_equal expected_etag, @response.headers['ETag'] - end - end - - def test_internal_calling - assert_deprecated do - get :internal_caller - assert_equal "Are you there? Yes, ma'am", @response.body - end - end - - def test_flash - assert_deprecated do - get :set_flash - assert_equal 'My stoney baby', flash[:notice] - get :use_flash - assert_equal 'My stoney baby', @response.body - get :use_flash - assert_equal 'no flash', @response.body - end - end - - def test_component_redirect_redirects - assert_deprecated do - get :calling_redirected - assert_redirected_to :controller=>"callee", :action => "being_called" - end - end - - def test_component_multiple_redirect_redirects - test_component_redirect_redirects - test_internal_calling - end - - def test_component_as_string_redirect_renders_redirected_action - assert_deprecated do - get :calling_redirected_as_string - assert_equal "Lady of the House, speaking", @response.body - end - end - - protected - def etag_for(text) - %("#{Digest::MD5.hexdigest(text)}") - end -end diff --git a/actionpack/test/controller/polymorphic_routes_test.rb b/actionpack/test/controller/polymorphic_routes_test.rb index efa3c44bc0..42dbea3b8f 100644 --- a/actionpack/test/controller/polymorphic_routes_test.rb +++ b/actionpack/test/controller/polymorphic_routes_test.rb @@ -179,6 +179,12 @@ uses_mocha 'polymorphic URL helpers' do polymorphic_url([nil, @article]) end + def test_with_array_containing_single_name + @article.save + expects(:articles_url) + polymorphic_url([:articles]) + end + # TODO: Needs to be updated to correctly know about whether the object is in a hash or not def xtest_with_hash expects(:article_url).with(@article) diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 462fba7045..d5320596d5 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -246,6 +246,15 @@ class TestController < ActionController::Base :locals => { :local_name => name } end + def helper_method_to_render_to_string(*args) + render_to_string(*args) + end + helper_method :helper_method_to_render_to_string + + def render_html_only_partial_within_inline + render :inline => "Hello world <%= helper_method_to_render_to_string :partial => 'test/partial_with_only_html_version' %>" + end + def formatted_html_erb end @@ -932,6 +941,11 @@ class RenderTest < ActionController::TestCase assert_equal "Goodbye, Local David", @response.body end + def test_rendering_html_only_partial_within_inline_with_js + get :render_html_only_partial_within_inline, :format => :js + assert_equal "Hello world partial with only html version", @response.body + end + def test_should_render_formatted_template get :formatted_html_erb assert_equal 'formatted html erb', @response.body diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 9699a04abb..b8a143cfd9 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -706,12 +706,13 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do port = options.delete(:port) || 80 port_string = port == 80 ? '' : ":#{port}" - host = options.delete(:host) || "named.route.test" - anchor = "##{options.delete(:anchor)}" if options.key?(:anchor) + protocol = options.delete(:protocol) || "http" + host = options.delete(:host) || "named.route.test" + anchor = "##{options.delete(:anchor)}" if options.key?(:anchor) path = routes.generate(options) - only_path ? "#{path}#{anchor}" : "http://#{host}#{port_string}#{path}#{anchor}" + only_path ? "#{path}#{anchor}" : "#{protocol}://#{host}#{port_string}#{path}#{anchor}" end def request @@ -1726,6 +1727,11 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do assert_equal "http://some.example.com/people/5", controller.send(:show_url, 5, :host=>"some.example.com") end + def test_named_route_url_method_with_protocol + controller = setup_named_route_test + assert_equal "https://named.route.test/people/5", controller.send(:show_url, 5, :protocol => "https") + end + def test_named_route_url_method_with_ordered_parameters controller = setup_named_route_test assert_equal "http://named.route.test/people/go/7/hello/joe/5", |