From c08547d2266c75f0a82d06dd91c6d0500740e12e Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 3 Jun 2008 13:32:53 -0500 Subject: Namespace Inflector, Dependencies, OrderedOptions, and TimeZone under ActiveSupport [#238 state:resolved] --- actionpack/test/controller/dispatcher_test.rb | 4 ++-- actionpack/test/controller/integration_upload_test.rb | 2 +- actionpack/test/controller/routing_test.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/dispatcher_test.rb b/actionpack/test/controller/dispatcher_test.rb index eea0813ed5..911fcab67b 100644 --- a/actionpack/test/controller/dispatcher_test.rb +++ b/actionpack/test/controller/dispatcher_test.rb @@ -27,14 +27,14 @@ class DispatcherTest < Test::Unit::TestCase def test_clears_dependencies_after_dispatch_if_in_loading_mode ActionController::Routing::Routes.expects(:reload).once - Dependencies.expects(:clear).once + ActiveSupport::Dependencies.expects(:clear).once dispatch(@output, false) end def test_leaves_dependencies_after_dispatch_if_not_in_loading_mode ActionController::Routing::Routes.expects(:reload).never - Dependencies.expects(:clear).never + ActiveSupport::Dependencies.expects(:clear).never dispatch end diff --git a/actionpack/test/controller/integration_upload_test.rb b/actionpack/test/controller/integration_upload_test.rb index 33df1131cb..4af9b7e697 100644 --- a/actionpack/test/controller/integration_upload_test.rb +++ b/actionpack/test/controller/integration_upload_test.rb @@ -28,7 +28,7 @@ class SessionUploadTest < ActionController::IntegrationTest # end def test_post_with_upload uses_mocha "test_post_with_upload" do - Dependencies.stubs(:load?).returns(false) + ActiveSupport::Dependencies.stubs(:load?).returns(false) with_routing do |set| set.draw do |map| map.update 'update', :controller => "upload_test", :action => "update", :method => :post diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 5e5503fd52..068d71a8f8 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -2392,10 +2392,10 @@ uses_mocha 'route loading' do end def test_adding_inflections_forces_reload - Inflector::Inflections.instance.expects(:uncountable).with('equipment') + ActiveSupport::Inflector::Inflections.instance.expects(:uncountable).with('equipment') routes.expects(:reload!) - Inflector.inflections { |inflect| inflect.uncountable('equipment') } + ActiveSupport::Inflector.inflections { |inflect| inflect.uncountable('equipment') } end def test_load_with_configuration -- cgit v1.2.3 From d54d90f2b590c763fe710482a9b993923fe03ec0 Mon Sep 17 00:00:00 2001 From: josevalim Date: Tue, 3 Jun 2008 14:02:51 -0500 Subject: Allow caches_action to accept a layout option [#198 state:resolved] Signed-off-by: Joshua Peek --- actionpack/test/controller/caching_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index f9b6b87bc6..c6d61bb504 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -156,6 +156,7 @@ class ActionCachingTestController < ActionController::Base caches_action :show, :cache_path => 'http://test.host/custom/show' caches_action :edit, :cache_path => Proc.new { |c| c.params[:id] ? "http://test.host/#{c.params[:id]};edit" : "http://test.host/edit" } caches_action :with_layout + caches_action :layout_false, :layout => false layout 'talk_from_action.erb' @@ -181,6 +182,7 @@ class ActionCachingTestController < ActionController::Base alias_method :show, :index alias_method :edit, :index alias_method :destroy, :index + alias_method :layout_false, :with_layout def expire expire_action :controller => 'action_caching_test', :action => 'index' @@ -263,6 +265,19 @@ class ActionCacheTest < Test::Unit::TestCase assert_equal @response.body, read_fragment('hostname.com/action_caching_test/with_layout') end + def test_action_cache_with_layout_and_layout_cache_false + get :layout_false + cached_time = content_to_cache + assert_not_equal cached_time, @response.body + assert fragment_exist?('hostname.com/action_caching_test/layout_false') + reset! + + get :layout_false + assert_not_equal cached_time, @response.body + + assert_equal cached_time, read_fragment('hostname.com/action_caching_test/layout_false') + end + def test_action_cache_conditional_options @request.env['HTTP_ACCEPT'] = 'application/json' get :index -- cgit v1.2.3 From 025515b234d8380f195e3de3818d076302605b12 Mon Sep 17 00:00:00 2001 From: Gabe da Silveira Date: Mon, 2 Jun 2008 19:57:35 -0300 Subject: Fix assert_redirected_to for nested controllers and named routes [#308 state:resolved] Signed-off-by: Michael Koziarski --- .../test/controller/action_pack_assertions_test.rb | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (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 f152b1d19c..c25e9e1df6 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -137,6 +137,9 @@ class AssertResponseWithUnexpectedErrorController < ActionController::Base end end +class UserController < ActionController::Base +end + module Admin class InnerModuleController < ActionController::Base def index @@ -174,7 +177,7 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase # let's get this party started def setup ActionController::Routing::Routes.reload - ActionController::Routing.use_controllers!(%w(action_pack_assertions admin/inner_module content admin/user)) + ActionController::Routing.use_controllers!(%w(action_pack_assertions admin/inner_module user content admin/user)) @controller = ActionPackAssertionsController.new @request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new end @@ -268,7 +271,7 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase assert_redirected_to admin_inner_module_path end end - + def test_assert_redirected_to_top_level_named_route_from_nested_controller with_routing do |set| set.draw do |map| @@ -277,11 +280,25 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase end @controller = Admin::InnerModuleController.new process :redirect_to_top_level_named_route - # passes -> assert_redirected_to "http://test.host/action_pack_assertions/foo" + # assert_redirected_to "http://test.host/action_pack_assertions/foo" would pass because of exact match early return assert_redirected_to "/action_pack_assertions/foo" end end + def test_assert_redirected_to_top_level_named_route_with_same_controller_name_in_both_namespaces + with_routing do |set| + set.draw do |map| + # this controller exists in the admin namespace as well which is the only difference from previous test + map.top_level '/user/:id', :controller => 'user', :action => 'index' + map.connect ':controller/:action/:id' + end + @controller = Admin::InnerModuleController.new + process :redirect_to_top_level_named_route + # assert_redirected_to top_level_url('foo') would pass because of exact match early return + assert_redirected_to top_level_path('foo') + end + end + # -- standard request/response object testing -------------------------------- # make sure that the template objects exist -- cgit v1.2.3 From edfa195e2ace7b4fb8195333c6e44e6bf8986c11 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 3 Jun 2008 18:11:47 -0500 Subject: Fixed Request#remote_ip to only raise hell if the HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR doesnt match (not just if theyre both present) [Mark Imbriaco, Bradford Folkens] --- actionpack/test/controller/request_test.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb index 82ddfec8e8..2bd489b2c7 100644 --- a/actionpack/test/controller/request_test.rb +++ b/actionpack/test/controller/request_test.rb @@ -59,6 +59,9 @@ class RequestTest < Test::Unit::TestCase assert_match /HTTP_X_FORWARDED_FOR="9.9.9.9, 3.4.5.6, 10.0.0.1, 172.31.4.4"/, e.message assert_match /HTTP_CLIENT_IP="8.8.8.8"/, e.message + @request.env['HTTP_X_FORWARDED_FOR'] = '8.8.8.8, 9.9.9.9' + assert_equal '8.8.8.8', @request.remote_ip + @request.env.delete 'HTTP_CLIENT_IP' @request.env.delete 'HTTP_X_FORWARDED_FOR' end -- cgit v1.2.3