From eec2d301d4ce9df9c71c1a5aa63053eb970b6818 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 15 Feb 2010 10:20:11 -0600 Subject: Fix test load paths for those not using bundler --- actionpack/test/controller/subscriber_test.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/subscriber_test.rb b/actionpack/test/controller/subscriber_test.rb index d7c1166f14..72368df93b 100644 --- a/actionpack/test/controller/subscriber_test.rb +++ b/actionpack/test/controller/subscriber_test.rb @@ -1,3 +1,6 @@ +railties_path = File.expand_path('../../../../railties/lib', __FILE__) +$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path) + require "abstract_unit" require "rails/subscriber/test_helper" require "action_controller/railties/subscriber" -- cgit v1.2.3 From f0523f72b46db14e2f50c8347a8708734c650f84 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Mon, 15 Feb 2010 21:44:30 +0700 Subject: Rename Rails::Subscriber to Rails::LogSubscriber --- actionpack/test/controller/log_subscriber_test.rb | 172 ++++++++++++++++++++++ actionpack/test/controller/subscriber_test.rb | 172 ---------------------- 2 files changed, 172 insertions(+), 172 deletions(-) create mode 100644 actionpack/test/controller/log_subscriber_test.rb delete mode 100644 actionpack/test/controller/subscriber_test.rb (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb new file mode 100644 index 0000000000..182f343b2f --- /dev/null +++ b/actionpack/test/controller/log_subscriber_test.rb @@ -0,0 +1,172 @@ +require "abstract_unit" +require "rails/log_subscriber/test_helper" +require "action_controller/railties/log_subscriber" + +module Another + class LogSubscribersController < ActionController::Base + def show + render :nothing => true + end + + def redirector + redirect_to "http://foo.bar/" + end + + def data_sender + send_data "cool data", :filename => "file.txt" + end + + def xfile_sender + send_file File.expand_path("company.rb", FIXTURE_LOAD_PATH), :x_sendfile => true + end + + def file_sender + send_file File.expand_path("company.rb", FIXTURE_LOAD_PATH) + end + + def with_fragment_cache + render :inline => "<%= cache('foo'){ 'bar' } %>" + end + + def with_page_cache + cache_page("Super soaker", "/index.html") + render :nothing => true + end + end +end + +class ACLogSubscriberTest < ActionController::TestCase + tests Another::LogSubscribersController + include Rails::LogSubscriber::TestHelper + + def setup + @old_logger = ActionController::Base.logger + + @cache_path = File.expand_path('../temp/test_cache', File.dirname(__FILE__)) + ActionController::Base.page_cache_directory = @cache_path + ActionController::Base.cache_store = :file_store, @cache_path + + Rails::LogSubscriber.add(:action_controller, ActionController::Railties::LogSubscriber.new) + super + end + + def teardown + super + Rails::LogSubscriber.log_subscribers.clear + FileUtils.rm_rf(@cache_path) + ActionController::Base.logger = @old_logger + end + + def set_logger(logger) + ActionController::Base.logger = logger + end + + def test_start_processing + get :show + wait + assert_equal 2, logs.size + assert_equal "Processing by Another::LogSubscribersController#show as HTML", logs.first + end + + def test_process_action + get :show + wait + assert_equal 2, logs.size + assert_match /Completed/, logs.last + assert_match /200 OK/, logs.last + end + + def test_process_action_without_parameters + get :show + wait + assert_nil logs.detect {|l| l =~ /Parameters/ } + end + + def test_process_action_with_parameters + get :show, :id => '10' + wait + + assert_equal 3, logs.size + assert_equal 'Parameters: {"id"=>"10"}', logs[1] + end + + def test_process_action_with_view_runtime + get :show + wait + assert_match /\(Views: [\d\.]+ms\)/, logs[1] + end + + def test_process_action_with_filter_parameters + @request.env["action_dispatch.parameter_filter"] = [:lifo, :amount] + + get :show, :lifo => 'Pratik', :amount => '420', :step => '1' + wait + + params = logs[1] + assert_match /"amount"=>"\[FILTERED\]"/, params + assert_match /"lifo"=>"\[FILTERED\]"/, params + assert_match /"step"=>"1"/, params + end + + def test_redirect_to + get :redirector + wait + + assert_equal 3, logs.size + assert_equal "Redirected to http://foo.bar/", logs[1] + end + + def test_send_data + get :data_sender + wait + + assert_equal 3, logs.size + assert_match /Sent data file\.txt/, logs[1] + end + + def test_send_file + get :file_sender + wait + + assert_equal 3, logs.size + assert_match /Sent file/, logs[1] + assert_match /test\/fixtures\/company\.rb/, logs[1] + end + + def test_send_xfile + get :xfile_sender + wait + + assert_equal 3, logs.size + assert_match /Sent X\-Sendfile header/, logs[1] + assert_match /test\/fixtures\/company\.rb/, logs[1] + end + + def test_with_fragment_cache + ActionController::Base.perform_caching = true + get :with_fragment_cache + wait + + assert_equal 4, logs.size + assert_match /Exist fragment\? views\/foo/, logs[1] + assert_match /Write fragment views\/foo/, logs[2] + ensure + ActionController::Base.perform_caching = true + end + + def test_with_page_cache + ActionController::Base.perform_caching = true + get :with_page_cache + wait + + assert_equal 3, logs.size + assert_match /Write page/, logs[1] + assert_match /\/index\.html/, logs[1] + ensure + ActionController::Base.perform_caching = true + end + + def logs + @logs ||= @logger.logged(:info) + end +end diff --git a/actionpack/test/controller/subscriber_test.rb b/actionpack/test/controller/subscriber_test.rb deleted file mode 100644 index d7c1166f14..0000000000 --- a/actionpack/test/controller/subscriber_test.rb +++ /dev/null @@ -1,172 +0,0 @@ -require "abstract_unit" -require "rails/subscriber/test_helper" -require "action_controller/railties/subscriber" - -module Another - class SubscribersController < ActionController::Base - def show - render :nothing => true - end - - def redirector - redirect_to "http://foo.bar/" - end - - def data_sender - send_data "cool data", :filename => "file.txt" - end - - def xfile_sender - send_file File.expand_path("company.rb", FIXTURE_LOAD_PATH), :x_sendfile => true - end - - def file_sender - send_file File.expand_path("company.rb", FIXTURE_LOAD_PATH) - end - - def with_fragment_cache - render :inline => "<%= cache('foo'){ 'bar' } %>" - end - - def with_page_cache - cache_page("Super soaker", "/index.html") - render :nothing => true - end - end -end - -class ACSubscriberTest < ActionController::TestCase - tests Another::SubscribersController - include Rails::Subscriber::TestHelper - - def setup - @old_logger = ActionController::Base.logger - - @cache_path = File.expand_path('../temp/test_cache', File.dirname(__FILE__)) - ActionController::Base.page_cache_directory = @cache_path - ActionController::Base.cache_store = :file_store, @cache_path - - Rails::Subscriber.add(:action_controller, ActionController::Railties::Subscriber.new) - super - end - - def teardown - super - Rails::Subscriber.subscribers.clear - FileUtils.rm_rf(@cache_path) - ActionController::Base.logger = @old_logger - end - - def set_logger(logger) - ActionController::Base.logger = logger - end - - def test_start_processing - get :show - wait - assert_equal 2, logs.size - assert_equal "Processing by Another::SubscribersController#show as HTML", logs.first - end - - def test_process_action - get :show - wait - assert_equal 2, logs.size - assert_match /Completed/, logs.last - assert_match /200 OK/, logs.last - end - - def test_process_action_without_parameters - get :show - wait - assert_nil logs.detect {|l| l =~ /Parameters/ } - end - - def test_process_action_with_parameters - get :show, :id => '10' - wait - - assert_equal 3, logs.size - assert_equal 'Parameters: {"id"=>"10"}', logs[1] - end - - def test_process_action_with_view_runtime - get :show - wait - assert_match /\(Views: [\d\.]+ms\)/, logs[1] - end - - def test_process_action_with_filter_parameters - @request.env["action_dispatch.parameter_filter"] = [:lifo, :amount] - - get :show, :lifo => 'Pratik', :amount => '420', :step => '1' - wait - - params = logs[1] - assert_match /"amount"=>"\[FILTERED\]"/, params - assert_match /"lifo"=>"\[FILTERED\]"/, params - assert_match /"step"=>"1"/, params - end - - def test_redirect_to - get :redirector - wait - - assert_equal 3, logs.size - assert_equal "Redirected to http://foo.bar/", logs[1] - end - - def test_send_data - get :data_sender - wait - - assert_equal 3, logs.size - assert_match /Sent data file\.txt/, logs[1] - end - - def test_send_file - get :file_sender - wait - - assert_equal 3, logs.size - assert_match /Sent file/, logs[1] - assert_match /test\/fixtures\/company\.rb/, logs[1] - end - - def test_send_xfile - get :xfile_sender - wait - - assert_equal 3, logs.size - assert_match /Sent X\-Sendfile header/, logs[1] - assert_match /test\/fixtures\/company\.rb/, logs[1] - end - - def test_with_fragment_cache - ActionController::Base.perform_caching = true - get :with_fragment_cache - wait - - assert_equal 4, logs.size - assert_match /Exist fragment\? views\/foo/, logs[1] - assert_match /Write fragment views\/foo/, logs[2] - ensure - ActionController::Base.perform_caching = true - end - - def test_with_page_cache - ActionController::Base.perform_caching = true - get :with_page_cache - wait - - assert_equal 3, logs.size - assert_match /Write page/, logs[1] - assert_match /\/index\.html/, logs[1] - ensure - ActionController::Base.perform_caching = true - end - - def logs - @logs ||= @logger.logged(:info) - end -end -- cgit v1.2.3 From b1edd096626d6f536b87ff5e307c37a89dd78133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 16 Feb 2010 23:26:29 +0100 Subject: Ensure render :text => resource first tries to invoke :to_text on it --- actionpack/test/controller/render_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 2c3dc2a72d..eceec3b08e 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -214,6 +214,10 @@ class TestController < ActionController::Base render :text => false end + def render_text_with_resource + render :text => Customer.new("David") + end + # :ported: def render_nothing_with_appendix render :text => "appended" @@ -817,6 +821,11 @@ class RenderTest < ActionController::TestCase assert_equal 'appended', @response.body end + def test_render_text_with_resource + get :render_text_with_resource + assert_equal 'name: David', @response.body + end + # :ported: def test_attempt_to_access_object_method assert_raise(ActionController::UnknownAction, "No action responded to [clone]") { get :clone } -- cgit v1.2.3 From e8ef12e39d4af20c5211cd92aa560590fa5387cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 17 Feb 2010 00:14:49 +0100 Subject: Make Railties tests green again. --- actionpack/test/controller/render_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index eceec3b08e..3cc22cc316 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -823,7 +823,7 @@ class RenderTest < ActionController::TestCase def test_render_text_with_resource get :render_text_with_resource - assert_equal 'name: David', @response.body + assert_equal 'name: "David"', @response.body end # :ported: -- cgit v1.2.3 From 7d7f9ccfdf986099e3c5abf05af37a886daba0b5 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Fri, 19 Feb 2010 09:31:10 -0600 Subject: Reinstate pending tests that were supposed to be fixed before the beta. Shout louder this time so they actually get fixed. --- actionpack/test/controller/send_file_test.rb | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb index 0afebac68c..aebbd893a8 100644 --- a/actionpack/test/controller/send_file_test.rb +++ b/actionpack/test/controller/send_file_test.rb @@ -51,19 +51,17 @@ class SendFileTest < ActionController::TestCase end def test_file_stream - pending do - response = nil - assert_nothing_raised { response = process('file') } - assert_not_nil response - assert_kind_of Array, response.body_parts - - require 'stringio' - output = StringIO.new - output.binmode - output.string.force_encoding(file_data.encoding) if output.string.respond_to?(:force_encoding) - assert_nothing_raised { response.body_parts.each { |part| output << part.to_s } } - assert_equal file_data, output.string - end + response = nil + assert_nothing_raised { response = process('file') } + assert_not_nil response + assert_kind_of Array, response.body_parts + + require 'stringio' + output = StringIO.new + output.binmode + output.string.force_encoding(file_data.encoding) if output.string.respond_to?(:force_encoding) + assert_nothing_raised { response.body_parts.each { |part| output << part.to_s } } + assert_equal file_data, output.string end def test_file_url_based_filename -- cgit v1.2.3 From a3c6ad7d5e567cf4d688147357c5de134763599d Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Fri, 19 Feb 2010 19:19:20 -0800 Subject: Fix a bunch of pending tests by providing an introspection mode for the Response object that does up-front parsing of the headers to populate things like @etag --- actionpack/test/controller/send_file_test.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb index aebbd893a8..31177223e4 100644 --- a/actionpack/test/controller/send_file_test.rb +++ b/actionpack/test/controller/send_file_test.rb @@ -102,7 +102,7 @@ class SendFileTest < ActionController::TestCase end # Test that send_file_headers! is setting the correct HTTP headers. - def test_send_file_headers! + def test_send_file_headers_bang options = { :length => 1, :type => Mime::PNG, @@ -125,7 +125,6 @@ class SendFileTest < ActionController::TestCase assert_equal 'binary', h['Content-Transfer-Encoding'] # test overriding Cache-Control: no-cache header to fix IE open/save dialog - @controller.headers = { 'Cache-Control' => 'no-cache' } @controller.send(:send_file_headers!, options) @controller.response.prepare! assert_equal 'private', h['Cache-Control'] -- cgit v1.2.3 From f81c6bc0404ba2a03eed0ec6c08bbac45661305f Mon Sep 17 00:00:00 2001 From: snusnu Date: Sun, 21 Feb 2010 03:05:28 +0100 Subject: AMo #key is now #to_key and CI is probably happy Obviously #key is a too common name to be included in the AMo interface, #to_key fits better and also relates nicely to #to_param. Thx wycats, koz and josevalim for the suggestion. AR's #to_key implementation now takes customized primary keys into account and there's a testcase for that too. The #to_param AMo lint makes no assumptions on how the method behaves in the presence of composite primary keys. It leaves the decision wether to provide a default, or to raise and thus signal to the user that implementing this method will need his special attention, up to the implementers. All AMo cares about is that #to_param is implemented and returns nil in case of a new_record?. The default CompliantObject used in lint_test provides a naive default implementation that just joins all key attributes with '-'. The #to_key default implementation in lint_test's CompliantObject now returns [id] instead of [1]. This was previously causing the (wrong) tests I added for AR's #to_key implementation to pass. The #to_key tests added with this patch should be better. The CI failure was caused by my lack of knowledge about the test:isolated task. The tests for the record_identifier code in action_controller are using fake non AR models and I forgot to stub the #to_key method over there. This issue didn't come up when running the test task, only test:isolated revealed it. This patch fixes that. All tests pass isolated or not, well, apart from one previously unpended test in action_controller that is unrelated to my patch. --- actionpack/test/controller/record_identifier_test.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/record_identifier_test.rb b/actionpack/test/controller/record_identifier_test.rb index 6b6d154faa..813dedc80d 100644 --- a/actionpack/test/controller/record_identifier_test.rb +++ b/actionpack/test/controller/record_identifier_test.rb @@ -5,6 +5,7 @@ class Comment include ActiveModel::Conversion attr_reader :id + def to_key; id ? [id] : nil end def save; @id = 1 end def new_record?; @id.nil? end def name -- cgit v1.2.3 From 250c8092461f5e6bf62751b313f6605a37fd1b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 21 Feb 2010 11:09:21 +0100 Subject: Require persisted? in ActiveModel::Lint and remove new_record? and destroyed? methods. ActionPack does not care if the resource is new or if it was destroyed, it cares only if it's persisted somewhere or not. --- actionpack/test/controller/mime_responds_test.rb | 4 ++-- actionpack/test/controller/redirect_test.rb | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index 3bd3369242..5e34773899 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -513,7 +513,7 @@ class RespondWithController < ActionController::Base protected def resource - Customer.new("david", 13) + Customer.new("david", request.delete? ? nil : 13) end def _render_js(js, options) @@ -717,7 +717,7 @@ class RespondWithControllerTest < ActionController::TestCase delete :using_resource assert_equal "text/html", @response.content_type assert_equal 302, @response.status - assert_equal "http://www.example.com/customers/13", @response.location + assert_equal "http://www.example.com/customers", @response.location end end diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb index 570ff4a41b..441bc47908 100644 --- a/actionpack/test/controller/redirect_test.rb +++ b/actionpack/test/controller/redirect_test.rb @@ -6,14 +6,14 @@ end class Workshop extend ActiveModel::Naming include ActiveModel::Conversion - attr_accessor :id, :new_record + attr_accessor :id - def initialize(id, new_record) - @id, @new_record = id, new_record + def initialize(id) + @id = id end - def new_record? - @new_record + def persisted? + id.present? end def to_s @@ -88,11 +88,11 @@ class RedirectController < ActionController::Base end def redirect_to_existing_record - redirect_to Workshop.new(5, false) + redirect_to Workshop.new(5) end def redirect_to_new_record - redirect_to Workshop.new(5, true) + redirect_to Workshop.new(nil) end def redirect_to_nil @@ -239,11 +239,11 @@ class RedirectTest < ActionController::TestCase get :redirect_to_existing_record assert_equal "http://test.host/workshops/5", redirect_to_url - assert_redirected_to Workshop.new(5, false) + assert_redirected_to Workshop.new(5) get :redirect_to_new_record assert_equal "http://test.host/workshops", redirect_to_url - assert_redirected_to Workshop.new(5, true) + assert_redirected_to Workshop.new(nil) end end -- cgit v1.2.3 From 6bc24d40d56332593bc22612d4618a2f80b1d91b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=BCrrer?= Date: Sun, 21 Feb 2010 17:21:25 +0100 Subject: Use ActionDispatch::Routing everywhere --- actionpack/test/controller/rescue_test.rb | 4 ++-- actionpack/test/controller/resources_test.rb | 4 ++-- actionpack/test/controller/test_test.rb | 8 ++++---- actionpack/test/controller/webservice_test.rb | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb index 37367eaafc..118b563a72 100644 --- a/actionpack/test/controller/rescue_test.rb +++ b/actionpack/test/controller/rescue_test.rb @@ -326,7 +326,7 @@ class RescueTest < ActionController::IntegrationTest end test 'rescue routing exceptions' do - @app = ActionDispatch::Rescue.new(ActionController::Routing::Routes) do + @app = ActionDispatch::Rescue.new(ActionDispatch::Routing::Routes) do rescue_from ActionController::RoutingError, lambda { |env| [200, {"Content-Type" => "text/html"}, ["Gotcha!"]] } end @@ -335,7 +335,7 @@ class RescueTest < ActionController::IntegrationTest end test 'unrescued exception' do - @app = ActionDispatch::Rescue.new(ActionController::Routing::Routes) + @app = ActionDispatch::Rescue.new(ActionDispatch::Routing::Routes) assert_raise(ActionController::RoutingError) { get '/b00m' } end diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index 01ed491732..9b3f466e44 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -394,7 +394,7 @@ class ResourcesTest < ActionController::TestCase assert_restful_routes_for :messages do |options| assert_recognizes(options.merge(:action => "new"), :path => "/messages/new", :method => :get) assert_raise(ActionController::RoutingError) do - ActionController::Routing::Routes.recognize_path("/messages/new", :method => :post) + ActionDispatch::Routing::Routes.recognize_path("/messages/new", :method => :post) end end end @@ -504,7 +504,7 @@ class ResourcesTest < ActionController::TestCase def test_restful_routes_dont_generate_duplicates with_restful_routing :messages do - routes = ActionController::Routing::Routes.routes + routes = ActionDispatch::Routing::Routes.routes routes.each do |route| routes.each do |r| next if route === r # skip the comparison instance diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index 0f074b32e6..3f5d60540f 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -476,8 +476,8 @@ XML end def test_with_routing_places_routes_back - assert ActionController::Routing::Routes - routes_id = ActionController::Routing::Routes.object_id + assert ActionDispatch::Routing::Routes + routes_id = ActionDispatch::Routing::Routes.object_id begin with_routing { raise 'fail' } @@ -485,8 +485,8 @@ XML rescue RuntimeError end - assert ActionController::Routing::Routes - assert_equal routes_id, ActionController::Routing::Routes.object_id + assert ActionDispatch::Routing::Routes + assert_equal routes_id, ActionDispatch::Routing::Routes.object_id end def test_remote_addr diff --git a/actionpack/test/controller/webservice_test.rb b/actionpack/test/controller/webservice_test.rb index 5882a8cfa3..ede48017cf 100644 --- a/actionpack/test/controller/webservice_test.rb +++ b/actionpack/test/controller/webservice_test.rb @@ -245,7 +245,7 @@ class WebServiceTest < ActionController::IntegrationTest private def with_params_parsers(parsers = {}) old_session = @integration_session - @app = ActionDispatch::ParamsParser.new(ActionController::Routing::Routes, parsers) + @app = ActionDispatch::ParamsParser.new(ActionDispatch::Routing::Routes, parsers) reset! yield ensure -- cgit v1.2.3 From 3345af61fb128d0a70793b235e3cb878781d6f40 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Tue, 23 Feb 2010 15:37:17 -0800 Subject: Fix streaming by having it create a File object, which can be handled by Rack servers as appropriate --- actionpack/test/controller/send_file_test.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb index 31177223e4..ce144cc24b 100644 --- a/actionpack/test/controller/send_file_test.rb +++ b/actionpack/test/controller/send_file_test.rb @@ -46,15 +46,17 @@ class SendFileTest < ActionController::TestCase response = nil assert_nothing_raised { response = process('file') } assert_not_nil response - assert_kind_of String, response.body - assert_equal file_data, response.body + body = response.body + assert_kind_of String, body + assert_equal file_data, body end def test_file_stream response = nil assert_nothing_raised { response = process('file') } assert_not_nil response - assert_kind_of Array, response.body_parts + assert response.body_parts.respond_to?(:each) + assert response.body_parts.respond_to?(:to_path) require 'stringio' output = StringIO.new @@ -160,6 +162,12 @@ class SendFileTest < ActionController::TestCase assert_equal 500, @response.status end + define_method "test_send_#{method}_content_type" do + @controller.options = { :stream => false, :content_type => "application/x-ruby" } + assert_nothing_raised { assert_not_nil process(method) } + assert_equal "application/x-ruby", @response.content_type + end + define_method "test_default_send_#{method}_status" do @controller.options = { :stream => false } assert_nothing_raised { assert_not_nil process(method) } -- cgit v1.2.3 From 5e2bd08023344f3fd4675e80203a10967ffe9000 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Tue, 23 Feb 2010 17:03:06 -0800 Subject: Makes send_file work again by deferring to Rack::Sendfile. * Add the Rack::Sendfile middleware * Make the header to use configurable via config.action_dispatch.x_sendfile_header (default to "X-Sendfile"). * Add Railties tests to confirm that these work * Remove the :stream, :buffer_size, and :x_senfile default options to send_file * Change the log subscriber to always say "Sent file" * Add deprecation warnings for options that are now no-ops Note that servers can configure this by setting X-Sendfile-Type. Hosting companies and those creating packages of servers specially designed for Rails applications are encouraged to specify this header so that this can work transparently. --- actionpack/test/controller/log_subscriber_test.rb | 4 ++-- actionpack/test/controller/send_file_test.rb | 23 ----------------------- 2 files changed, 2 insertions(+), 25 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb index 0659a4520e..5a3a2dd3ea 100644 --- a/actionpack/test/controller/log_subscriber_test.rb +++ b/actionpack/test/controller/log_subscriber_test.rb @@ -137,11 +137,11 @@ class ACLogSubscriberTest < ActionController::TestCase end def test_send_xfile - get :xfile_sender + assert_deprecated { get :xfile_sender } wait assert_equal 3, logs.size - assert_match /Sent X\-Sendfile header/, logs[1] + assert_match /Sent file/, logs[1] assert_match /test\/fixtures\/company\.rb/, logs[1] end diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb index ce144cc24b..30c9a65b7c 100644 --- a/actionpack/test/controller/send_file_test.rb +++ b/actionpack/test/controller/send_file_test.rb @@ -74,18 +74,6 @@ class SendFileTest < ActionController::TestCase assert_equal "attachment", response.headers["Content-Disposition"] end - def test_x_sendfile_header - @controller.options = { :x_sendfile => true } - - response = nil - assert_nothing_raised { response = process('file') } - assert_not_nil response - - assert_equal @controller.file_path, response.headers['X-Sendfile'] - assert response.body.blank? - assert !response.etag? - end - def test_data response = nil assert_nothing_raised { response = process('data') } @@ -106,7 +94,6 @@ class SendFileTest < ActionController::TestCase # Test that send_file_headers! is setting the correct HTTP headers. def test_send_file_headers_bang options = { - :length => 1, :type => Mime::PNG, :disposition => 'disposition', :filename => 'filename' @@ -121,7 +108,6 @@ class SendFileTest < ActionController::TestCase @controller.send(:send_file_headers!, options) h = @controller.headers - assert_equal '1', h['Content-Length'] assert_equal 'image/png', @controller.content_type assert_equal 'disposition; filename="filename"', h['Content-Disposition'] assert_equal 'binary', h['Content-Transfer-Encoding'] @@ -134,7 +120,6 @@ class SendFileTest < ActionController::TestCase def test_send_file_headers_with_mime_lookup_with_symbol options = { - :length => 1, :type => :png } @@ -147,7 +132,6 @@ class SendFileTest < ActionController::TestCase def test_send_file_headers_with_bad_symbol options = { - :length => 1, :type => :this_type_is_not_registered } @@ -174,11 +158,4 @@ class SendFileTest < ActionController::TestCase assert_equal 200, @response.status end end - - def test_send_data_content_length_header - @controller.headers = {} - @controller.options = { :type => :text, :filename => 'file_with_utf8_text' } - process('multibyte_text_data') - assert_equal '29', @controller.headers['Content-Length'] - end end -- cgit v1.2.3 From 24ab5665b2f12a589e96a4b742cc49c08bf0e9df Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Tue, 23 Feb 2010 17:31:17 -0800 Subject: Revert "Fix test load paths for those not using bundler" This reverts commit eec2d301d4ce9df9c71c1a5aa63053eb970b6818. This commit broke tests. You cannot have a file called "bundler" on the load path. --- actionpack/test/controller/log_subscriber_test.rb | 3 --- 1 file changed, 3 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb index 5a3a2dd3ea..668d6ae5ea 100644 --- a/actionpack/test/controller/log_subscriber_test.rb +++ b/actionpack/test/controller/log_subscriber_test.rb @@ -1,6 +1,3 @@ -railties_path = File.expand_path('../../../../railties/lib', __FILE__) -$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path) - require "abstract_unit" require "rails/log_subscriber/test_helper" require "action_controller/railties/log_subscriber" -- cgit v1.2.3 From ae933a093db93c22b9facd3411afd9ef69719193 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Tue, 23 Feb 2010 22:45:42 -0800 Subject: Fix render :file => "#{Rails.root}/public/404.html", :status => :not_found. Closes #8994 --- actionpack/test/controller/render_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 3cc22cc316..ecfe14b797 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -21,6 +21,10 @@ class TestController < ActionController::Base def hello_world end + def hello_world_file + render :file => File.expand_path("../../fixtures/hello.html", __FILE__) + end + def conditional_hello if stale?(:last_modified => Time.now.utc.beginning_of_day, :etag => [:foo, 123]) render :action => 'hello_world' @@ -751,6 +755,11 @@ class RenderTest < ActionController::TestCase assert_equal "The secret is in the sauce\n", @response.body end + def test_render_file + get :hello_world_file + assert_equal "Hello world!", @response.body + end + # :ported: def test_render_file_as_string_with_instance_variables get :render_file_as_string_with_instance_variables -- cgit v1.2.3 From 6a061187e26f0942c458a859c8e941ed092a48c1 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 23 Feb 2010 19:53:52 -0800 Subject: Remove ActionController::Base.resources_path_names --- actionpack/test/controller/resources_test.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index 9b3f466e44..cce98ac482 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -31,10 +31,10 @@ end class ResourcesTest < ActionController::TestCase def test_should_arrange_actions - resource = ActionDispatch::Routing::DeprecatedMapper::Resource.new(:messages, + resource = ActionDispatch::Routing::DeprecatedMapper::Resource.new(:messages, { :collection => { :rss => :get, :reorder => :post, :csv => :post }, :member => { :rss => :get, :atom => :get, :upload => :post, :fix => :post }, - :new => { :preview => :get, :draft => :get }) + :new => { :preview => :get, :draft => :get }}, {}) assert_resource_methods [:rss], resource, :collection, :get assert_resource_methods [:csv, :reorder], resource, :collection, :post @@ -44,18 +44,18 @@ class ResourcesTest < ActionController::TestCase end def test_should_resource_controller_name_equal_resource_name_by_default - resource = ActionDispatch::Routing::DeprecatedMapper::Resource.new(:messages, {}) + resource = ActionDispatch::Routing::DeprecatedMapper::Resource.new(:messages, {}, {}) assert_equal 'messages', resource.controller end def test_should_resource_controller_name_equal_controller_option - resource = ActionDispatch::Routing::DeprecatedMapper::Resource.new(:messages, :controller => 'posts') + resource = ActionDispatch::Routing::DeprecatedMapper::Resource.new(:messages, {:controller => 'posts'}, {}) assert_equal 'posts', resource.controller end def test_should_all_singleton_paths_be_the_same [ :path, :nesting_path_prefix, :member_path ].each do |method| - resource = ActionDispatch::Routing::DeprecatedMapper::SingletonResource.new(:messages, :path_prefix => 'admin') + resource = ActionDispatch::Routing::DeprecatedMapper::SingletonResource.new(:messages, {:path_prefix => 'admin'}, {}) assert_equal 'admin/messages', resource.send(method) end end @@ -111,8 +111,8 @@ class ResourcesTest < ActionController::TestCase end def test_override_paths_for_default_restful_actions - resource = ActionDispatch::Routing::DeprecatedMapper::Resource.new(:messages, - :path_names => {:new => 'nuevo', :edit => 'editar'}) + resource = ActionDispatch::Routing::DeprecatedMapper::Resource.new(:messages, { + :path_names => {:new => 'nuevo', :edit => 'editar'}}, {}) assert_equal resource.new_path, "#{resource.path}/nuevo" end @@ -1162,8 +1162,9 @@ class ResourcesTest < ActionController::TestCase options[:shallow_options] = options[:options] end - new_action = ActionController::Base.resources_path_names[:new] || "new" - edit_action = ActionController::Base.resources_path_names[:edit] || "edit" + new_action = ActionDispatch::Routing::Routes.resources_path_names[:new] || "new" + edit_action = ActionDispatch::Routing::Routes.resources_path_names[:edit] || "edit" + if options[:path_names] new_action = options[:path_names][:new] if options[:path_names][:new] edit_action = options[:path_names][:edit] if options[:path_names][:edit] -- cgit v1.2.3 From a39c7505bd69e9da0a122fbb8fe20612390c57ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 24 Feb 2010 19:17:24 +0100 Subject: Cleanup render callstack and make render(:json => {}, :status => 401) work again. --- actionpack/test/controller/render_json_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/render_json_test.rb b/actionpack/test/controller/render_json_test.rb index 3938fc7061..2580ada88b 100644 --- a/actionpack/test/controller/render_json_test.rb +++ b/actionpack/test/controller/render_json_test.rb @@ -18,6 +18,10 @@ class RenderJsonTest < ActionController::TestCase render :json => ActiveSupport::JSON.encode(:hello => 'world') end + def render_json_hello_world_with_status + render :json => ActiveSupport::JSON.encode(:hello => 'world'), :status => 401 + end + def render_json_hello_world_with_callback render :json => ActiveSupport::JSON.encode(:hello => 'world'), :callback => 'alert' end @@ -58,6 +62,12 @@ class RenderJsonTest < ActionController::TestCase assert_equal 'application/json', @response.content_type end + def test_render_json_with_status + get :render_json_hello_world_with_status + assert_equal '{"hello":"world"}', @response.body + assert_equal 401, @response.status + end + def test_render_json_with_callback get :render_json_hello_world_with_callback assert_equal 'alert({"hello":"world"})', @response.body -- cgit v1.2.3 From 226dfc2681c98deaf14e4ae82e973d1d5caedd68 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Wed, 24 Feb 2010 16:01:03 -0800 Subject: WIP: Remove the global router --- .../test/controller/action_pack_assertions_test.rb | 9 ++++-- actionpack/test/controller/base_test.rb | 4 ++- actionpack/test/controller/integration_test.rb | 11 ++++++-- actionpack/test/controller/rescue_test.rb | 4 +-- actionpack/test/controller/resources_test.rb | 13 +++++---- actionpack/test/controller/test_test.rb | 8 +++--- actionpack/test/controller/url_for_test.rb | 2 +- actionpack/test/controller/url_rewriter_test.rb | 32 +++++++++++----------- 8 files changed, 48 insertions(+), 35 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index d54be9bdc0..7c83a91f4d 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -253,12 +253,13 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase end def test_assert_redirect_to_nested_named_route + @controller = Admin::InnerModuleController.new + with_routing do |set| set.draw do |map| match 'admin/inner_module', :to => 'admin/inner_module#index', :as => :admin_inner_module match ':controller/:action' end - @controller = Admin::InnerModuleController.new process :redirect_to_index # redirection is <{"action"=>"index", "controller"=>"admin/admin/inner_module"}> assert_redirected_to admin_inner_module_path @@ -266,12 +267,13 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase end def test_assert_redirected_to_top_level_named_route_from_nested_controller + @controller = Admin::InnerModuleController.new + with_routing do |set| set.draw do |map| match '/action_pack_assertions/:id', :to => 'action_pack_assertions#index', :as => :top_level match ':controller/:action' end - @controller = Admin::InnerModuleController.new process :redirect_to_top_level_named_route # 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" @@ -279,13 +281,14 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase end def test_assert_redirected_to_top_level_named_route_with_same_controller_name_in_both_namespaces + @controller = Admin::InnerModuleController.new + 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 match '/user/:id', :to => 'user#index', :as => :top_level match ':controller/:action' 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') diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index 4fcfbacf4e..25006dda76 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -219,12 +219,14 @@ class EmptyUrlOptionsTest < ActionController::TestCase end def test_named_routes_with_path_without_doing_a_request_first + @controller = EmptyController.new + with_routing do |set| set.draw do |map| resources :things end - assert_equal '/things', EmptyController.new.send(:things_path) + assert_equal '/things', @controller.send(:things_path) end end end diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 683ab5236c..29531d237a 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -86,7 +86,7 @@ class SessionTest < Test::Unit::TestCase def test_url_for_without_controller options = {:action => 'show'} mock_rewriter = mock() - mock_rewriter.expects(:rewrite).with(options).returns('/show') + mock_rewriter.expects(:rewrite).with(SharedTestRoutes, options).returns('/show') @session.stubs(:generic_url_rewriter).returns(mock_rewriter) @session.stubs(:controller).returns(nil) assert_equal '/show', @session.url_for(options) @@ -401,9 +401,14 @@ class IntegrationProcessTest < ActionController::IntegrationTest private def with_test_route_set with_routing do |set| + controller = ::IntegrationProcessTest::IntegrationController.clone + controller.class_eval do + include set.named_url_helpers + end + set.draw do |map| - match ':action', :to => ::IntegrationProcessTest::IntegrationController - get 'get/:action', :to => ::IntegrationProcessTest::IntegrationController + match ':action', :to => controller + get 'get/:action', :to => controller end yield end diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb index 118b563a72..dd991898a8 100644 --- a/actionpack/test/controller/rescue_test.rb +++ b/actionpack/test/controller/rescue_test.rb @@ -326,7 +326,7 @@ class RescueTest < ActionController::IntegrationTest end test 'rescue routing exceptions' do - @app = ActionDispatch::Rescue.new(ActionDispatch::Routing::Routes) do + @app = ActionDispatch::Rescue.new(SharedTestRoutes) do rescue_from ActionController::RoutingError, lambda { |env| [200, {"Content-Type" => "text/html"}, ["Gotcha!"]] } end @@ -335,7 +335,7 @@ class RescueTest < ActionController::IntegrationTest end test 'unrescued exception' do - @app = ActionDispatch::Rescue.new(ActionDispatch::Routing::Routes) + @app = ActionDispatch::Rescue.new(SharedTestRoutes) assert_raise(ActionController::RoutingError) { get '/b00m' } end diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index cce98ac482..6f3c16f588 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -125,7 +125,7 @@ class ResourcesTest < ActionController::TestCase def test_with_custom_conditions with_restful_routing :messages, :conditions => { :subdomain => 'app' } do - assert ActionDispatch::Routing::Routes.recognize_path("/messages", :method => :get, :subdomain => 'app') + assert @router.recognize_path("/messages", :method => :get, :subdomain => 'app') end end @@ -394,7 +394,7 @@ class ResourcesTest < ActionController::TestCase assert_restful_routes_for :messages do |options| assert_recognizes(options.merge(:action => "new"), :path => "/messages/new", :method => :get) assert_raise(ActionController::RoutingError) do - ActionDispatch::Routing::Routes.recognize_path("/messages/new", :method => :post) + @router.recognize_path("/messages/new", :method => :post) end end end @@ -504,7 +504,7 @@ class ResourcesTest < ActionController::TestCase def test_restful_routes_dont_generate_duplicates with_restful_routing :messages do - routes = ActionDispatch::Routing::Routes.routes + routes = @router.routes routes.each do |route| routes.each do |r| next if route === r # skip the comparison instance @@ -1162,8 +1162,8 @@ class ResourcesTest < ActionController::TestCase options[:shallow_options] = options[:options] end - new_action = ActionDispatch::Routing::Routes.resources_path_names[:new] || "new" - edit_action = ActionDispatch::Routing::Routes.resources_path_names[:edit] || "edit" + new_action = @router.resources_path_names[:new] || "new" + edit_action = @router.resources_path_names[:edit] || "edit" if options[:path_names] new_action = options[:path_names][:new] if options[:path_names][:new] @@ -1230,6 +1230,8 @@ class ResourcesTest < ActionController::TestCase end @controller = "#{options[:options][:controller].camelize}Controller".constantize.new + # ROUTES TODO: Figure out a way to not extend the routing helpers here + @controller.metaclass.send(:include, @router.named_url_helpers) @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new get :index, options[:options] @@ -1299,6 +1301,7 @@ class ResourcesTest < ActionController::TestCase def assert_singleton_named_routes_for(singleton_name, options = {}) (options[:options] ||= {})[:controller] ||= singleton_name.to_s.pluralize @controller = "#{options[:options][:controller].camelize}Controller".constantize.new + @controller.metaclass.send(:include, @router.named_url_helpers) @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new get :show, options[:options] diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index 3f5d60540f..d716dc2661 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -476,8 +476,8 @@ XML end def test_with_routing_places_routes_back - assert ActionDispatch::Routing::Routes - routes_id = ActionDispatch::Routing::Routes.object_id + assert @router + routes_id = @router.object_id begin with_routing { raise 'fail' } @@ -485,8 +485,8 @@ XML rescue RuntimeError end - assert ActionDispatch::Routing::Routes - assert_equal routes_id, ActionDispatch::Routing::Routes.object_id + assert @router + assert_equal routes_id, @router.object_id end def test_remote_addr diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb index 749fa5861f..43e2f91693 100644 --- a/actionpack/test/controller/url_for_test.rb +++ b/actionpack/test/controller/url_for_test.rb @@ -5,7 +5,7 @@ module AbstractController class UrlForTests < ActionController::TestCase class W - include ActionController::UrlFor + include SharedTestRoutes.url_helpers end def teardown diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb index c2b8cd85d8..199b824a7a 100644 --- a/actionpack/test/controller/url_rewriter_test.rb +++ b/actionpack/test/controller/url_rewriter_test.rb @@ -12,52 +12,52 @@ class UrlRewriterTests < ActionController::TestCase def test_port assert_equal('http://test.host:1271/c/a/i', - @rewriter.rewrite(:controller => 'c', :action => 'a', :id => 'i', :port => 1271) + @rewriter.rewrite(@router, :controller => 'c', :action => 'a', :id => 'i', :port => 1271) ) end def test_protocol_with_and_without_separator assert_equal('https://test.host/c/a/i', - @rewriter.rewrite(:protocol => 'https', :controller => 'c', :action => 'a', :id => 'i') + @rewriter.rewrite(@router, :protocol => 'https', :controller => 'c', :action => 'a', :id => 'i') ) assert_equal('https://test.host/c/a/i', - @rewriter.rewrite(:protocol => 'https://', :controller => 'c', :action => 'a', :id => 'i') + @rewriter.rewrite(@router, :protocol => 'https://', :controller => 'c', :action => 'a', :id => 'i') ) end def test_user_name_and_password assert_equal( 'http://david:secret@test.host/c/a/i', - @rewriter.rewrite(:user => "david", :password => "secret", :controller => 'c', :action => 'a', :id => 'i') + @rewriter.rewrite(@router, :user => "david", :password => "secret", :controller => 'c', :action => 'a', :id => 'i') ) end def test_user_name_and_password_with_escape_codes assert_equal( 'http://openid.aol.com%2Fnextangler:one+two%3F@test.host/c/a/i', - @rewriter.rewrite(:user => "openid.aol.com/nextangler", :password => "one two?", :controller => 'c', :action => 'a', :id => 'i') + @rewriter.rewrite(@router, :user => "openid.aol.com/nextangler", :password => "one two?", :controller => 'c', :action => 'a', :id => 'i') ) end def test_anchor assert_equal( 'http://test.host/c/a/i#anchor', - @rewriter.rewrite(:controller => 'c', :action => 'a', :id => 'i', :anchor => 'anchor') + @rewriter.rewrite(@router, :controller => 'c', :action => 'a', :id => 'i', :anchor => 'anchor') ) end def test_anchor_should_call_to_param assert_equal( 'http://test.host/c/a/i#anchor', - @rewriter.rewrite(:controller => 'c', :action => 'a', :id => 'i', :anchor => Struct.new(:to_param).new('anchor')) + @rewriter.rewrite(@router, :controller => 'c', :action => 'a', :id => 'i', :anchor => Struct.new(:to_param).new('anchor')) ) end def test_anchor_should_be_cgi_escaped assert_equal( 'http://test.host/c/a/i#anc%2Fhor', - @rewriter.rewrite(:controller => 'c', :action => 'a', :id => 'i', :anchor => Struct.new(:to_param).new('anc/hor')) + @rewriter.rewrite(@router, :controller => 'c', :action => 'a', :id => 'i', :anchor => Struct.new(:to_param).new('anc/hor')) ) end @@ -66,8 +66,8 @@ class UrlRewriterTests < ActionController::TestCase @params[:action] = 'bye' @params[:id] = '2' - assert_equal '/hi/hi/2', @rewriter.rewrite(:only_path => true, :overwrite_params => {:action => 'hi'}) - u = @rewriter.rewrite(:only_path => false, :overwrite_params => {:action => 'hi'}) + assert_equal '/hi/hi/2', @rewriter.rewrite(@router, :only_path => true, :overwrite_params => {:action => 'hi'}) + u = @rewriter.rewrite(@router, :only_path => false, :overwrite_params => {:action => 'hi'}) assert_match %r(/hi/hi/2$), u end @@ -76,8 +76,8 @@ class UrlRewriterTests < ActionController::TestCase @params[:action] = 'list' @params[:list_page] = 1 - assert_equal '/search/list?list_page=2', @rewriter.rewrite(:only_path => true, :overwrite_params => {"list_page" => 2}) - u = @rewriter.rewrite(:only_path => false, :overwrite_params => {:list_page => 2}) + assert_equal '/search/list?list_page=2', @rewriter.rewrite(@router, :only_path => true, :overwrite_params => {"list_page" => 2}) + u = @rewriter.rewrite(@router, :only_path => false, :overwrite_params => {:list_page => 2}) assert_equal 'http://test.host/search/list?list_page=2', u end @@ -91,12 +91,12 @@ class UrlRewriterTests < ActionController::TestCase def test_trailing_slash options = {:controller => 'foo', :action => 'bar', :id => '3', :only_path => true} - assert_equal '/foo/bar/3', @rewriter.rewrite(options) - assert_equal '/foo/bar/3?query=string', @rewriter.rewrite(options.merge({:query => 'string'})) + assert_equal '/foo/bar/3', @rewriter.rewrite(@router, options) + assert_equal '/foo/bar/3?query=string', @rewriter.rewrite(@router, options.merge({:query => 'string'})) options.update({:trailing_slash => true}) - assert_equal '/foo/bar/3/', @rewriter.rewrite(options) + assert_equal '/foo/bar/3/', @rewriter.rewrite(@router, options) options.update({:query => 'string'}) - assert_equal '/foo/bar/3/?query=string', @rewriter.rewrite(options) + assert_equal '/foo/bar/3/?query=string', @rewriter.rewrite(@router, options) end end -- cgit v1.2.3 From 4b038f638d8c8969b2bccac82d0d7a370381680b Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Wed, 24 Feb 2010 16:01:32 -0800 Subject: Merge branch 'master' of github.com:rails/rails --- actionpack/test/controller/webservice_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/webservice_test.rb b/actionpack/test/controller/webservice_test.rb index ede48017cf..05545395fb 100644 --- a/actionpack/test/controller/webservice_test.rb +++ b/actionpack/test/controller/webservice_test.rb @@ -245,7 +245,7 @@ class WebServiceTest < ActionController::IntegrationTest private def with_params_parsers(parsers = {}) old_session = @integration_session - @app = ActionDispatch::ParamsParser.new(ActionDispatch::Routing::Routes, parsers) + @app = ActionDispatch::ParamsParser.new(app.router, parsers) reset! yield ensure -- cgit v1.2.3 From a278f2331007411b190d65577082d2710ad9a996 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Wed, 24 Feb 2010 16:17:04 -0800 Subject: Fix all of AP's tests with the non global router --- actionpack/test/controller/caching_test.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index de92fc56fd..9c9d886f5d 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -74,9 +74,9 @@ class PageCachingTest < ActionController::TestCase match '/', :to => 'posts#index', :as => :main end @params[:format] = 'rss' - assert_equal '/posts.rss', @rewriter.rewrite(@params) + assert_equal '/posts.rss', @rewriter.rewrite(@router, @params) @params[:format] = nil - assert_equal '/', @rewriter.rewrite(@params) + assert_equal '/', @rewriter.rewrite(@router, @params) end end @@ -511,6 +511,8 @@ class ActionCacheTest < ActionController::TestCase @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @controller = ActionCachingTestController.new + # ROUTES TODO: It seems bad to explicitly remix in the class + @controller.metaclass.send(:include, @router.named_url_helpers) @request.host = 'hostname.com' end -- cgit v1.2.3 From 36fd9efb5e4bfc9ac3acd4189d4dc457dea8102a Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Thu, 25 Feb 2010 15:05:10 -0800 Subject: Continued effort to deglobalize the router --- actionpack/test/controller/base_test.rb | 1 + actionpack/test/controller/routing_test.rb | 34 ++++++------------------------ 2 files changed, 8 insertions(+), 27 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index 25006dda76..436ee212c8 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -220,6 +220,7 @@ class EmptyUrlOptionsTest < ActionController::TestCase def test_named_routes_with_path_without_doing_a_request_first @controller = EmptyController.new + @controller.request = @request with_routing do |set| set.draw do |map| diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index f390bbdc89..f2fccfbcfc 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -52,29 +52,11 @@ class UriReservedCharactersRoutingTest < Test::Unit::TestCase end class MockController - attr_accessor :routes - - def initialize(routes) - self.routes = routes - end - def url_for(options) - only_path = options.delete(:only_path) - - port = options.delete(:port) || 80 - port_string = port == 80 ? '' : ":#{port}" - - protocol = options.delete(:protocol) || "http" - host = options.delete(:host) || "test.host" - anchor = "##{options.delete(:anchor)}" if options.key?(:anchor) + options[:protocol] ||= "http" + options[:host] ||= "test.host" - path = routes.generate(options) - - only_path ? "#{path}#{anchor}" : "#{protocol}://#{host}#{port_string}#{path}#{anchor}" - end - - def request - @request ||= ActionController::TestRequest.new + super(options) end end @@ -268,9 +250,9 @@ class LegacyRouteSetTests < Test::Unit::TestCase end def setup_for_named_route - klass = Class.new(MockController) - rs.install_helpers(klass) - klass.new(rs) + inst = MockController.clone.new + inst.class.send(:include, rs.named_url_helpers) + inst end def test_named_route_without_hash @@ -759,9 +741,7 @@ class RouteSetTest < ActiveSupport::TestCase map.users '/admin/users', :controller => 'admin/users', :action => 'index' end - klass = Class.new(MockController) - set.install_helpers(klass) - klass.new(set) + MockController.clone.new.tap { |inst| inst.class.send(:include, set.named_url_helpers)} end def test_named_route_hash_access_method -- cgit v1.2.3 From 8760add31a0415b4635059cf7fadabc26946c0c2 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Thu, 25 Feb 2010 17:51:56 -0800 Subject: Get URL helpers working again in integration tests. --- actionpack/test/controller/integration_test.rb | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 29531d237a..1611a549fd 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -75,23 +75,6 @@ class SessionTest < Test::Unit::TestCase @session.delete_via_redirect(path, args, headers) end - def test_url_for_with_controller - options = {:action => 'show'} - mock_controller = mock() - mock_controller.expects(:url_for).with(options).returns('/show') - @session.stubs(:controller).returns(mock_controller) - assert_equal '/show', @session.url_for(options) - end - - def test_url_for_without_controller - options = {:action => 'show'} - mock_rewriter = mock() - mock_rewriter.expects(:rewrite).with(SharedTestRoutes, options).returns('/show') - @session.stubs(:generic_url_rewriter).returns(mock_rewriter) - @session.stubs(:controller).returns(nil) - assert_equal '/show', @session.url_for(options) - end - def test_get path = "/index"; params = "blah"; headers = {:location => 'blah'} @session.expects(:process).with(:get,path,params,headers) @@ -238,6 +221,8 @@ class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest end class IntegrationProcessTest < ActionController::IntegrationTest + include SharedTestRoutes.named_url_helpers + class IntegrationController < ActionController::Base def get respond_to do |format| @@ -410,12 +395,17 @@ class IntegrationProcessTest < ActionController::IntegrationTest match ':action', :to => controller get 'get/:action', :to => controller end + + self.metaclass.send(:include, set.named_url_helpers) + yield end end end class MetalIntegrationTest < ActionController::IntegrationTest + include SharedTestRoutes.named_url_helpers + class Poller def self.call(env) if env["PATH_INFO"] =~ /^\/success/ -- cgit v1.2.3 From f863045c45fbbe5972f557c02b729441ffe81502 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Thu, 25 Feb 2010 17:56:58 -0800 Subject: Rename metaclass to singleton_class --- actionpack/test/controller/caching_test.rb | 2 +- actionpack/test/controller/integration_test.rb | 2 +- actionpack/test/controller/resources_test.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 9c9d886f5d..98cea945a7 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -512,7 +512,7 @@ class ActionCacheTest < ActionController::TestCase @response = ActionController::TestResponse.new @controller = ActionCachingTestController.new # ROUTES TODO: It seems bad to explicitly remix in the class - @controller.metaclass.send(:include, @router.named_url_helpers) + @controller.singleton_class.send(:include, @router.named_url_helpers) @request.host = 'hostname.com' end diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 1611a549fd..437d26e4ed 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -396,7 +396,7 @@ class IntegrationProcessTest < ActionController::IntegrationTest get 'get/:action', :to => controller end - self.metaclass.send(:include, set.named_url_helpers) + self.singleton_class.send(:include, set.named_url_helpers) yield end diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index 6f3c16f588..b377e5bbbc 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -1231,7 +1231,7 @@ class ResourcesTest < ActionController::TestCase @controller = "#{options[:options][:controller].camelize}Controller".constantize.new # ROUTES TODO: Figure out a way to not extend the routing helpers here - @controller.metaclass.send(:include, @router.named_url_helpers) + @controller.singleton_class.send(:include, @router.named_url_helpers) @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new get :index, options[:options] @@ -1301,7 +1301,7 @@ class ResourcesTest < ActionController::TestCase def assert_singleton_named_routes_for(singleton_name, options = {}) (options[:options] ||= {})[:controller] ||= singleton_name.to_s.pluralize @controller = "#{options[:options][:controller].camelize}Controller".constantize.new - @controller.metaclass.send(:include, @router.named_url_helpers) + @controller.singleton_class.send(:include, @router.named_url_helpers) @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new get :show, options[:options] -- cgit v1.2.3 From bd36418c512acb62c5515a6cbde79ce59dd67b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 26 Feb 2010 11:51:21 +0100 Subject: Fix controller_path returnsing an empty string in Ruby 1.8.7 [#4036 status:resolved] --- actionpack/test/controller/base_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index 436ee212c8..207dc63d57 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -113,6 +113,15 @@ class ControllerInstanceTests < Test::Unit::TestCase assert_equal Set.new(%w(public_action)), c.class.__send__(:action_methods), "#{c.controller_path} should not be empty!" end end + + def test_temporary_anonymous_controllers + name = 'ExamplesController' + klass = Class.new(ActionController::Base) + Object.const_set(name, klass) + + controller = klass.new + assert_equal "examples", controller.controller_path + end end class PerformActionTest < ActionController::TestCase -- cgit v1.2.3 From 98f77e08278658ec47c9eb2e8f819d781c1eaebf Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Fri, 26 Feb 2010 15:00:33 -0800 Subject: Rename named_url_helpers to url_helpers and url_helpers to url_for --- actionpack/test/controller/caching_test.rb | 2 +- actionpack/test/controller/integration_test.rb | 8 ++++---- actionpack/test/controller/resources_test.rb | 4 ++-- actionpack/test/controller/routing_test.rb | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 98cea945a7..67b6a1d858 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -512,7 +512,7 @@ class ActionCacheTest < ActionController::TestCase @response = ActionController::TestResponse.new @controller = ActionCachingTestController.new # ROUTES TODO: It seems bad to explicitly remix in the class - @controller.singleton_class.send(:include, @router.named_url_helpers) + @controller.singleton_class.send(:include, @router.url_helpers) @request.host = 'hostname.com' end diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 437d26e4ed..5352243734 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -221,7 +221,7 @@ class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest end class IntegrationProcessTest < ActionController::IntegrationTest - include SharedTestRoutes.named_url_helpers + include SharedTestRoutes.url_helpers class IntegrationController < ActionController::Base def get @@ -388,7 +388,7 @@ class IntegrationProcessTest < ActionController::IntegrationTest with_routing do |set| controller = ::IntegrationProcessTest::IntegrationController.clone controller.class_eval do - include set.named_url_helpers + include set.url_helpers end set.draw do |map| @@ -396,7 +396,7 @@ class IntegrationProcessTest < ActionController::IntegrationTest get 'get/:action', :to => controller end - self.singleton_class.send(:include, set.named_url_helpers) + self.singleton_class.send(:include, set.url_helpers) yield end @@ -404,7 +404,7 @@ class IntegrationProcessTest < ActionController::IntegrationTest end class MetalIntegrationTest < ActionController::IntegrationTest - include SharedTestRoutes.named_url_helpers + include SharedTestRoutes.url_helpers class Poller def self.call(env) diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index b377e5bbbc..cf0cab3690 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -1231,7 +1231,7 @@ class ResourcesTest < ActionController::TestCase @controller = "#{options[:options][:controller].camelize}Controller".constantize.new # ROUTES TODO: Figure out a way to not extend the routing helpers here - @controller.singleton_class.send(:include, @router.named_url_helpers) + @controller.singleton_class.send(:include, @router.url_helpers) @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new get :index, options[:options] @@ -1301,7 +1301,7 @@ class ResourcesTest < ActionController::TestCase def assert_singleton_named_routes_for(singleton_name, options = {}) (options[:options] ||= {})[:controller] ||= singleton_name.to_s.pluralize @controller = "#{options[:options][:controller].camelize}Controller".constantize.new - @controller.singleton_class.send(:include, @router.named_url_helpers) + @controller.singleton_class.send(:include, @router.url_helpers) @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new get :show, options[:options] diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index f2fccfbcfc..31f86d2dde 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -251,7 +251,7 @@ class LegacyRouteSetTests < Test::Unit::TestCase def setup_for_named_route inst = MockController.clone.new - inst.class.send(:include, rs.named_url_helpers) + inst.class.send(:include, rs.url_helpers) inst end @@ -741,7 +741,7 @@ class RouteSetTest < ActiveSupport::TestCase map.users '/admin/users', :controller => 'admin/users', :action => 'index' end - MockController.clone.new.tap { |inst| inst.class.send(:include, set.named_url_helpers)} + MockController.clone.new.tap { |inst| inst.class.send(:include, set.url_helpers)} end def test_named_route_hash_access_method -- cgit v1.2.3 From 47fe14bfcc553acfd4c44434636529f25054a751 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Fri, 26 Feb 2010 15:34:12 -0800 Subject: Silence test deprecation warnings --- actionpack/test/controller/base_test.rb | 71 +++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 16 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index 207dc63d57..ade9a7fcba 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -66,6 +66,16 @@ class DefaultUrlOptionsController < ActionController::Base end end +class UrlOptionsController < ActionController::Base + def from_view + render :inline => "<%= #{params[:route]} %>" + end + + def url_options + super.merge(:host => 'www.override.com', :action => 'new', :locale => 'en') + end +end + class ControllerClassTests < ActiveSupport::TestCase def test_controller_path assert_equal 'empty', EmptyController.controller_path @@ -162,8 +172,8 @@ class PerformActionTest < ActionController::TestCase end end -class DefaultUrlOptionsTest < ActionController::TestCase - tests DefaultUrlOptionsController +class UrlOptionsTest < ActionController::TestCase + tests UrlOptionsController def setup super @@ -174,7 +184,7 @@ class DefaultUrlOptionsTest < ActionController::TestCase def test_default_url_options_are_used_if_set with_routing do |set| set.draw do |map| - match 'from_view', :to => 'default_url_options#from_view', :as => :from_view + match 'from_view', :to => 'url_options#from_view', :as => :from_view match ':controller/:action' end @@ -184,6 +194,33 @@ class DefaultUrlOptionsTest < ActionController::TestCase assert_equal 'http://www.override.com/from_view?locale=en', @controller.send(:from_view_url) assert_equal 'http://www.override.com/default_url_options/new?locale=en', @controller.url_for(:controller => 'default_url_options') end + end +end + +class DefaultUrlOptionsTest < ActionController::TestCase + tests DefaultUrlOptionsController + + def setup + super + @request.host = 'www.example.com' + rescue_action_in_public! + end + + def test_default_url_options_are_used_if_set + with_routing do |set| + set.draw do |map| + match 'from_view', :to => 'default_url_options#from_view', :as => :from_view + match ':controller/:action' + end + + assert_deprecated do + get :from_view, :route => "from_view_url" + + assert_equal 'http://www.override.com/from_view?locale=en', @response.body + assert_equal 'http://www.override.com/from_view?locale=en', @controller.send(:from_view_url) + assert_equal 'http://www.override.com/default_url_options/new?locale=en', @controller.url_for(:controller => 'default_url_options') + end + end end def test_default_url_options_are_used_in_non_positional_parameters @@ -195,19 +232,21 @@ class DefaultUrlOptionsTest < ActionController::TestCase match ':controller/:action' end - get :from_view, :route => "description_path(1)" - - assert_equal '/en/descriptions/1', @response.body - assert_equal '/en/descriptions', @controller.send(:descriptions_path) - assert_equal '/pl/descriptions', @controller.send(:descriptions_path, "pl") - assert_equal '/pl/descriptions', @controller.send(:descriptions_path, :locale => "pl") - assert_equal '/pl/descriptions.xml', @controller.send(:descriptions_path, "pl", "xml") - assert_equal '/en/descriptions.xml', @controller.send(:descriptions_path, :format => "xml") - assert_equal '/en/descriptions/1', @controller.send(:description_path, 1) - assert_equal '/pl/descriptions/1', @controller.send(:description_path, "pl", 1) - assert_equal '/pl/descriptions/1', @controller.send(:description_path, 1, :locale => "pl") - assert_equal '/pl/descriptions/1.xml', @controller.send(:description_path, "pl", 1, "xml") - assert_equal '/en/descriptions/1.xml', @controller.send(:description_path, 1, :format => "xml") + assert_deprecated do + get :from_view, :route => "description_path(1)" + + assert_equal '/en/descriptions/1', @response.body + assert_equal '/en/descriptions', @controller.send(:descriptions_path) + assert_equal '/pl/descriptions', @controller.send(:descriptions_path, "pl") + assert_equal '/pl/descriptions', @controller.send(:descriptions_path, :locale => "pl") + assert_equal '/pl/descriptions.xml', @controller.send(:descriptions_path, "pl", "xml") + assert_equal '/en/descriptions.xml', @controller.send(:descriptions_path, :format => "xml") + assert_equal '/en/descriptions/1', @controller.send(:description_path, 1) + assert_equal '/pl/descriptions/1', @controller.send(:description_path, "pl", 1) + assert_equal '/pl/descriptions/1', @controller.send(:description_path, 1, :locale => "pl") + assert_equal '/pl/descriptions/1.xml', @controller.send(:description_path, "pl", 1, "xml") + assert_equal '/en/descriptions/1.xml', @controller.send(:description_path, 1, :format => "xml") + end end end -- cgit v1.2.3 From ab0cc7286fdaed96ff03bf8a160ccc75c3a2916d Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Fri, 26 Feb 2010 15:56:38 -0800 Subject: Setting UrlFor in with_routing is no longer needed now that it's not global --- actionpack/test/controller/url_for_test.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb index 43e2f91693..a7b77edc6e 100644 --- a/actionpack/test/controller/url_for_test.rb +++ b/actionpack/test/controller/url_for_test.rb @@ -132,7 +132,8 @@ module AbstractController end # We need to create a new class in order to install the new named route. - kls = Class.new { include ActionController::UrlFor } + kls = Class.new { include set.url_helpers } + controller = kls.new assert controller.respond_to?(:home_url) assert_equal 'http://www.basecamphq.com/home/sweet/home/again', @@ -153,7 +154,7 @@ module AbstractController match '/home/sweet/home/:user', :to => 'home#index', :as => :home end - kls = Class.new { include ActionController::UrlFor } + kls = Class.new { include set.url_helpers } controller = kls.new assert_equal 'http://www.basecamphq.com/subdir/home/sweet/home/again', @@ -171,7 +172,7 @@ module AbstractController end # We need to create a new class in order to install the new named route. - kls = Class.new { include ActionController::UrlFor } + kls = Class.new { include set.url_helpers } controller = kls.new assert controller.respond_to?(:home_url) assert_equal '/brave/new/world', @@ -239,7 +240,7 @@ module AbstractController end # We need to create a new class in order to install the new named route. - kls = Class.new { include ActionController::UrlFor } + kls = Class.new { include set.url_helpers } kls.default_url_options[:host] = 'www.basecamphq.com' controller = kls.new -- cgit v1.2.3 From 050831803a9e553ba392a73732b00528dfa8c6ad Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Fri, 26 Feb 2010 17:18:29 -0800 Subject: If IntegrationSession is initialized with an objects that responds to #routes, automatically extend the URL helpers from the RouteSet onto it --- actionpack/test/controller/caching_test.rb | 1 - actionpack/test/controller/integration_test.rb | 6 ++---- actionpack/test/controller/resources_test.rb | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 67b6a1d858..80c968cc04 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -511,7 +511,6 @@ class ActionCacheTest < ActionController::TestCase @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @controller = ActionCachingTestController.new - # ROUTES TODO: It seems bad to explicitly remix in the class @controller.singleton_class.send(:include, @router.url_helpers) @request.host = 'hostname.com' end diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 5352243734..c38348fa68 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -178,8 +178,8 @@ class IntegrationTestTest < Test::Unit::TestCase session1 = @test.open_session { |sess| } session2 = @test.open_session # implicit session - assert_equal ::ActionController::Integration::Session, session1.class - assert_equal ::ActionController::Integration::Session, session2.class + assert_kind_of ::ActionController::Integration::Session, session1 + assert_kind_of ::ActionController::Integration::Session, session2 assert_not_equal session1, session2 end @@ -221,8 +221,6 @@ class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest end class IntegrationProcessTest < ActionController::IntegrationTest - include SharedTestRoutes.url_helpers - class IntegrationController < ActionController::Base def get respond_to do |format| diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index cf0cab3690..f60045bba6 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -1230,7 +1230,6 @@ class ResourcesTest < ActionController::TestCase end @controller = "#{options[:options][:controller].camelize}Controller".constantize.new - # ROUTES TODO: Figure out a way to not extend the routing helpers here @controller.singleton_class.send(:include, @router.url_helpers) @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new -- cgit v1.2.3 From 4bdc783d37b82b739c5ddcc828d3a253873f6629 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Fri, 26 Feb 2010 18:25:56 -0800 Subject: 1.9 seems to have a bug involving cloned classes and super. Fix it by not cloning (and instead creating classes on demand). The 1.9 bug should be investigated. --- actionpack/test/controller/routing_test.rb | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 31f86d2dde..fc85b01394 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -52,11 +52,17 @@ class UriReservedCharactersRoutingTest < Test::Unit::TestCase end class MockController - def url_for(options) - options[:protocol] ||= "http" - options[:host] ||= "test.host" + def self.build(helpers) + Class.new do + def url_for(options) + options[:protocol] ||= "http" + options[:host] ||= "test.host" - super(options) + super(options) + end + + include helpers + end end end @@ -250,9 +256,7 @@ class LegacyRouteSetTests < Test::Unit::TestCase end def setup_for_named_route - inst = MockController.clone.new - inst.class.send(:include, rs.url_helpers) - inst + MockController.build(rs.url_helpers).new end def test_named_route_without_hash @@ -741,7 +745,7 @@ class RouteSetTest < ActiveSupport::TestCase map.users '/admin/users', :controller => 'admin/users', :action => 'index' end - MockController.clone.new.tap { |inst| inst.class.send(:include, set.url_helpers)} + MockController.build(set.url_helpers).new end def test_named_route_hash_access_method -- cgit v1.2.3 From 7317d9ef4c1361219671dc4405a02ed3896f1742 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 28 Feb 2010 16:39:01 -0600 Subject: Remove implicit controller namespacing from new dsl --- actionpack/test/controller/action_pack_assertions_test.rb | 9 ++++++--- actionpack/test/controller/render_xml_test.rb | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index 7c83a91f4d..6906dc97e8 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -258,7 +258,8 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase with_routing do |set| set.draw do |map| match 'admin/inner_module', :to => 'admin/inner_module#index', :as => :admin_inner_module - match ':controller/:action' + # match ':controller/:action' + map.connect ':controller/:action/:id' end process :redirect_to_index # redirection is <{"action"=>"index", "controller"=>"admin/admin/inner_module"}> @@ -272,7 +273,8 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase with_routing do |set| set.draw do |map| match '/action_pack_assertions/:id', :to => 'action_pack_assertions#index', :as => :top_level - match ':controller/:action' + # match ':controller/:action' + map.connect ':controller/:action/:id' end process :redirect_to_top_level_named_route # assert_redirected_to "http://test.host/action_pack_assertions/foo" would pass because of exact match early return @@ -287,7 +289,8 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase set.draw do |map| # this controller exists in the admin namespace as well which is the only difference from previous test match '/user/:id', :to => 'user#index', :as => :top_level - match ':controller/:action' + # match ':controller/:action' + map.connect ':controller/:action/:id' end process :redirect_to_top_level_named_route # assert_redirected_to top_level_url('foo') would pass because of exact match early return diff --git a/actionpack/test/controller/render_xml_test.rb b/actionpack/test/controller/render_xml_test.rb index b5b0d0b9d5..4da6c954cf 100644 --- a/actionpack/test/controller/render_xml_test.rb +++ b/actionpack/test/controller/render_xml_test.rb @@ -62,7 +62,8 @@ class RenderXmlTest < ActionController::TestCase with_routing do |set| set.draw do |map| resources :customers - match ':controller/:action' + # match ':controller/:action' + map.connect ':controller/:action/:id' end get :render_with_object_location -- cgit v1.2.3 From ecfd6d90eeeeeffb7415b4d9316da4e0bc35743b Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 2 Mar 2010 13:41:02 -0800 Subject: Action Mailer setup obviated by test bundle --- actionpack/test/controller/assert_select_test.rb | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/assert_select_test.rb b/actionpack/test/controller/assert_select_test.rb index 612827dd41..cb3e848dfa 100644 --- a/actionpack/test/controller/assert_select_test.rb +++ b/actionpack/test/controller/assert_select_test.rb @@ -6,18 +6,7 @@ require 'abstract_unit' require 'controller/fake_controllers' - -unless defined?(ActionMailer) - begin - $:.unshift("#{File.dirname(__FILE__)}/../../../actionmailer/lib") - require 'action_mailer' - rescue LoadError => e - raise unless e.message =~ /action_mailer/ - require 'rubygems' - gem 'actionmailer' - end -end - +require 'action_mailer' ActionMailer::Base.view_paths = FIXTURE_LOAD_PATH class AssertSelectTest < ActionController::TestCase -- cgit v1.2.3 From 9f83cdc38e03dc3e65a702b00dc4a3cc0bb44e60 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 2 Mar 2010 14:07:42 -0800 Subject: No longer add missing leading / on path args to assert_redirected_to. Deprecated in 2.3.6. --- actionpack/test/controller/action_pack_assertions_test.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index 6906dc97e8..26e0d6d844 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -469,9 +469,11 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase assert_redirected_to '/some/path' end - def test_redirected_to_url_no_leadling_slash + def test_redirected_to_url_no_leading_slash_fails process :redirect_to_path - assert_redirected_to 'some/path' + assert_raise ActiveSupport::TestCase::Assertion do + assert_redirected_to 'some/path' + end end def test_redirected_to_url_full_url -- cgit v1.2.3 From d78e3fe73fccb90ddb25dc04f9643b83cae2b9e3 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Tue, 2 Mar 2010 14:40:59 -0800 Subject: Fix failing Action Pack tests --- actionpack/test/controller/log_subscriber_test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb index 668d6ae5ea..1f8134822c 100644 --- a/actionpack/test/controller/log_subscriber_test.rb +++ b/actionpack/test/controller/log_subscriber_test.rb @@ -40,6 +40,8 @@ class ACLogSubscriberTest < ActionController::TestCase include Rails::LogSubscriber::TestHelper def setup + super + @old_logger = ActionController::Base.logger @cache_path = File.expand_path('../temp/test_cache', File.dirname(__FILE__)) @@ -47,7 +49,6 @@ class ACLogSubscriberTest < ActionController::TestCase ActionController::Base.cache_store = :file_store, @cache_path Rails::LogSubscriber.add(:action_controller, ActionController::Railties::LogSubscriber.new) - super end def teardown -- cgit v1.2.3 From bf9913f8f43a2436c644ad893d3d7034f7d7e256 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Tue, 2 Mar 2010 16:22:53 -0800 Subject: Move session_store and session_options to the AC configuration object --- actionpack/test/controller/http_digest_authentication_test.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/http_digest_authentication_test.rb b/actionpack/test/controller/http_digest_authentication_test.rb index 7e9a2625f1..22d2e23de1 100644 --- a/actionpack/test/controller/http_digest_authentication_test.rb +++ b/actionpack/test/controller/http_digest_authentication_test.rb @@ -40,7 +40,8 @@ class HttpDigestAuthenticationTest < ActionController::TestCase setup do # Used as secret in generating nonce to prevent tampering of timestamp - @old_secret, ActionController::Base.session_options[:secret] = ActionController::Base.session_options[:secret], "session_options_secret" + @secret = "session_options_secret" + @old_secret, ActionController::Base.session_options[:secret] = ActionController::Base.session_options[:secret], @secret end teardown do @@ -202,7 +203,7 @@ class HttpDigestAuthenticationTest < ActionController::TestCase test "validate_digest_response should fail with nil returning password_procedure" do @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => nil, :password => nil) - assert !ActionController::HttpAuthentication::Digest.validate_digest_response(@request, "SuperSecret"){nil} + assert !ActionController::HttpAuthentication::Digest.validate_digest_response(@secret, @request, "SuperSecret"){nil} end private -- cgit v1.2.3 From bcfb77782b9d7f28f0c19005da909162e5e27690 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Tue, 2 Mar 2010 17:20:13 -0800 Subject: Work on deprecating ActionController::Base.relative_url_root --- actionpack/test/controller/url_for_test.rb | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb index a7b77edc6e..07809aa480 100644 --- a/actionpack/test/controller/url_for_test.rb +++ b/actionpack/test/controller/url_for_test.rb @@ -113,15 +113,13 @@ module AbstractController end def test_relative_url_root_is_respected - orig_relative_url_root = ActionController::Base.relative_url_root - ActionController::Base.relative_url_root = '/subdir' + # ROUTES TODO: Tests should not have to pass :relative_url_root directly. This + # should probably come from the router. add_host! assert_equal('https://www.basecamphq.com/subdir/c/a/i', - W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https') + W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https', :relative_url_root => '/subdir') ) - ensure - ActionController::Base.relative_url_root = orig_relative_url_root end def test_named_routes @@ -146,9 +144,6 @@ module AbstractController end def test_relative_url_root_is_respected_for_named_routes - orig_relative_url_root = ActionController::Base.relative_url_root - ActionController::Base.relative_url_root = '/subdir' - with_routing do |set| set.draw do |map| match '/home/sweet/home/:user', :to => 'home#index', :as => :home @@ -158,10 +153,8 @@ module AbstractController controller = kls.new assert_equal 'http://www.basecamphq.com/subdir/home/sweet/home/again', - controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again') + controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again', :relative_url_root => "/subdir") end - ensure - ActionController::Base.relative_url_root = orig_relative_url_root end def test_only_path -- cgit v1.2.3 From 2a60cc682224f8a0923de1e0bf769d5333084480 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Wed, 3 Mar 2010 16:06:15 -0800 Subject: don't depend on the order of cookies (Hash ordering bug) --- actionpack/test/controller/cookie_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/cookie_test.rb b/actionpack/test/controller/cookie_test.rb index f5ccef8aaf..908967a110 100644 --- a/actionpack/test/controller/cookie_test.rb +++ b/actionpack/test/controller/cookie_test.rb @@ -157,7 +157,7 @@ class CookieTest < ActionController::TestCase def assert_cookie_header(expected) header = @response.headers["Set-Cookie"] if header.respond_to?(:to_str) - assert_equal expected, header + assert_equal expected.split("\n").sort, header.split("\n").sort else assert_equal expected.split("\n"), header end -- cgit v1.2.3 From 5e0a05b8cb236d285ebb45de006dd3600c69357d Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Tue, 2 Mar 2010 18:57:02 -0800 Subject: Tweak the semantic of various URL related methods of ActionDispatch::Request --- actionpack/test/controller/http_digest_authentication_test.rb | 10 ++++++---- actionpack/test/controller/integration_test.rb | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/http_digest_authentication_test.rb b/actionpack/test/controller/http_digest_authentication_test.rb index 22d2e23de1..6f167fe627 100644 --- a/actionpack/test/controller/http_digest_authentication_test.rb +++ b/actionpack/test/controller/http_digest_authentication_test.rb @@ -139,7 +139,7 @@ class HttpDigestAuthenticationTest < ActionController::TestCase test "authentication request with request-uri that doesn't match credentials digest-uri" do @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'please') - @request.env['REQUEST_URI'] = "/http_digest_authentication_test/dummy_digest/altered/uri" + @request.env['PATH_INFO'] = "/http_digest_authentication_test/dummy_digest/altered/uri" get :display assert_response :unauthorized @@ -148,7 +148,8 @@ class HttpDigestAuthenticationTest < ActionController::TestCase test "authentication request with absolute request uri (as in webrick)" do @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'please') - @request.env['REQUEST_URI'] = "http://test.host/http_digest_authentication_test/dummy_digest" + @request.env["SERVER_NAME"] = "test.host" + @request.env['PATH_INFO'] = "/http_digest_authentication_test/dummy_digest" get :display @@ -171,7 +172,8 @@ class HttpDigestAuthenticationTest < ActionController::TestCase test "authentication request with absolute uri in both request and credentials (as in Webrick with IE)" do @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:url => "http://test.host/http_digest_authentication_test/dummy_digest", :username => 'pretty', :password => 'please') - @request.env['REQUEST_URI'] = "http://test.host/http_digest_authentication_test/dummy_digest" + @request.env['SERVER_NAME'] = "test.host" + @request.env['PATH_INFO'] = "/http_digest_authentication_test/dummy_digest" get :display @@ -226,7 +228,7 @@ class HttpDigestAuthenticationTest < ActionController::TestCase credentials = decode_credentials(@response.headers['WWW-Authenticate']) credentials.merge!(options) - credentials.merge!(:uri => @request.env['REQUEST_URI'].to_s) + credentials.merge!(:uri => @request.env['PATH_INFO'].to_s) ActionController::HttpAuthentication::Digest.encode_credentials(method, credentials, password, options[:password_is_ha1]) end diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index c38348fa68..814699978d 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -346,8 +346,8 @@ class IntegrationProcessTest < ActionController::IntegrationTest def test_get_with_parameters with_test_route_set do get '/get_with_params', :foo => "bar" - assert_equal '/get_with_params', request.env["REQUEST_URI"] - assert_equal '/get_with_params', request.request_uri + assert_equal '/get_with_params', request.env["PATH_INFO"] + assert_equal '/get_with_params', request.path_info assert_equal 'foo=bar', request.env["QUERY_STRING"] assert_equal 'foo=bar', request.query_string assert_equal 'bar', request.parameters['foo'] -- cgit v1.2.3 From eb49bd694997954783632eada901553f041c9507 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Wed, 3 Mar 2010 00:03:56 -0800 Subject: Fix tests for the request refactor --- actionpack/test/controller/caching_test.rb | 3 ++- actionpack/test/controller/test_test.rb | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 80c968cc04..37f7483427 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -51,6 +51,7 @@ class PageCachingTest < ActionController::TestCase @request = ActionController::TestRequest.new @request.host = 'hostname.com' + @request.env.delete('PATH_INFO') @response = ActionController::TestResponse.new @controller = PageCachingTestController.new @@ -110,7 +111,7 @@ class PageCachingTest < ActionController::TestCase end def test_should_cache_ok_at_custom_path - @request.request_uri = "/index.html" + @request.env['PATH_INFO'] = '/index.html' get :ok assert_response :ok assert File.exist?("#{FILE_STORE_PATH}/index.html") diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index d716dc2661..7312c5dfcc 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -128,6 +128,7 @@ XML @controller = TestController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new + @request.env['PATH_INFO'] = nil end def test_raw_post_handling @@ -199,7 +200,7 @@ XML end def test_process_with_request_uri_with_params_with_explicit_uri - @request.request_uri = "/explicit/uri" + @request.env['PATH_INFO'] = "/explicit/uri" process :test_uri, :id => 7 assert_equal "/explicit/uri", @response.body end @@ -210,7 +211,8 @@ XML end def test_process_with_query_string_with_explicit_uri - @request.request_uri = "/explicit/uri?q=test?extra=question" + @request.env['PATH_INFO'] = '/explicit/uri' + @request.env['QUERY_STRING'] = 'q=test?extra=question' process :test_query_string assert_equal "q=test?extra=question", @response.body end -- cgit v1.2.3 From fb14b8c6fddae818b2688ac1e584534390c37f72 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Wed, 3 Mar 2010 00:31:55 -0800 Subject: ActionDispatch::Request deprecates #request_uri * Refactored ActionPatch to use fullpath instead --- actionpack/test/controller/integration_test.rb | 2 +- actionpack/test/controller/test_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 814699978d..5cb6aa6997 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -333,7 +333,7 @@ class IntegrationProcessTest < ActionController::IntegrationTest with_test_route_set do get '/get_with_params?foo=bar' assert_equal '/get_with_params?foo=bar', request.env["REQUEST_URI"] - assert_equal '/get_with_params?foo=bar', request.request_uri + assert_equal '/get_with_params?foo=bar', request.fullpath assert_equal "foo=bar", request.env["QUERY_STRING"] assert_equal 'foo=bar', request.query_string assert_equal 'bar', request.parameters['foo'] diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index 7312c5dfcc..f6ba275849 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -42,7 +42,7 @@ class TestTest < ActionController::TestCase end def test_uri - render :text => request.request_uri + render :text => request.fullpath end def test_query_string -- cgit v1.2.3 From 18bcce596efaa4e77a202431ab5e736001a394c6 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Wed, 3 Mar 2010 09:32:27 -0800 Subject: ActionController::Base.use_accept_header is not actually used anymore, so let's deprecate it. --- actionpack/test/controller/caching_test.rb | 3 --- actionpack/test/controller/content_type_test.rb | 12 ------------ actionpack/test/controller/mime_responds_test.rb | 4 ---- 3 files changed, 19 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 37f7483427..e42ef85b98 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -306,12 +306,9 @@ class ActionCacheTest < ActionController::TestCase end def test_action_cache_conditional_options - old_use_accept_header = ActionController::Base.use_accept_header - ActionController::Base.use_accept_header = true @request.env['HTTP_ACCEPT'] = 'application/json' get :index assert !fragment_exist?('hostname.com/action_caching_test') - ActionController::Base.use_accept_header = old_use_accept_header end def test_action_cache_with_store_options diff --git a/actionpack/test/controller/content_type_test.rb b/actionpack/test/controller/content_type_test.rb index e5ffe20ecc..967107853b 100644 --- a/actionpack/test/controller/content_type_test.rb +++ b/actionpack/test/controller/content_type_test.rb @@ -145,18 +145,6 @@ end class AcceptBasedContentTypeTest < ActionController::TestCase tests OldContentTypeController - def setup - super - @_old_accept_header = ActionController::Base.use_accept_header - ActionController::Base.use_accept_header = true - end - - def teardown - super - ActionController::Base.use_accept_header = @_old_accept_header - end - - def test_render_default_content_types_for_respond_to @request.accept = Mime::HTML.to_s get :render_default_content_types_for_respond_to diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index 5e34773899..5c1eaf453c 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -155,13 +155,11 @@ class RespondToControllerTest < ActionController::TestCase def setup super - ActionController::Base.use_accept_header = true @request.host = "www.example.com" end def teardown super - ActionController::Base.use_accept_header = false end def test_html @@ -544,13 +542,11 @@ class RespondWithControllerTest < ActionController::TestCase def setup super - ActionController::Base.use_accept_header = true @request.host = "www.example.com" end def teardown super - ActionController::Base.use_accept_header = false end def test_using_resource -- cgit v1.2.3 From 70916f6a9ce190cae5c545da552bb96f05ee4914 Mon Sep 17 00:00:00 2001 From: wycats Date: Thu, 4 Mar 2010 12:21:12 -0800 Subject: Fixes test ordering bug (ht: evan) --- actionpack/test/controller/view_paths_test.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/view_paths_test.rb b/actionpack/test/controller/view_paths_test.rb index 56821332c5..b8972b04b6 100644 --- a/actionpack/test/controller/view_paths_test.rb +++ b/actionpack/test/controller/view_paths_test.rb @@ -36,9 +36,12 @@ class ViewLoadPathsTest < ActionController::TestCase @old_behavior = ActiveSupport::Deprecation.behavior @last_message = nil ActiveSupport::Deprecation.behavior = Proc.new { |message, callback| @last_message = message } + + @paths = TestController.view_paths end def teardown + TestController.view_paths = @paths ActiveSupport::Deprecation.behavior = @old_behavior end -- cgit v1.2.3 From 5e3e5ac12baf8432b4c2a324a81fc81901479ef5 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 4 Mar 2010 15:31:22 -0800 Subject: Clarify cookie jar test --- actionpack/test/controller/integration_test.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 5cb6aa6997..2180466ca7 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -284,18 +284,13 @@ class IntegrationProcessTest < ActionController::IntegrationTest end end - def test_cookie_monster + test 'response cookies are added to the cookie jar for the next request' do with_test_route_set do self.cookies['cookie_1'] = "sugar" self.cookies['cookie_2'] = "oatmeal" get '/cookie_monster' - assert_equal 410, status - assert_equal "Gone", status_message - assert_response 410 - assert_response :gone assert_equal "cookie_1=; path=/\ncookie_3=chocolate; path=/", headers["Set-Cookie"] assert_equal({"cookie_1"=>"", "cookie_2"=>"oatmeal", "cookie_3"=>"chocolate"}, cookies.to_hash) - assert_equal "Gone", response.body end end -- cgit v1.2.3 From e311622e7b20b3fdeab6a93418c8a45c6e7137b6 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Thu, 4 Mar 2010 15:06:25 -0800 Subject: Deprecated ActionController::Base.session_options= and ActionController::Base.session_store= in favor of a config.session_store method (which takes params) and a config.cookie_secret variable, which is used in various secret scenarios. The old AC::Base options will continue to work with deprecation warnings. --- actionpack/test/controller/http_digest_authentication_test.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/http_digest_authentication_test.rb b/actionpack/test/controller/http_digest_authentication_test.rb index 6f167fe627..eb2af523a2 100644 --- a/actionpack/test/controller/http_digest_authentication_test.rb +++ b/actionpack/test/controller/http_digest_authentication_test.rb @@ -41,11 +41,12 @@ class HttpDigestAuthenticationTest < ActionController::TestCase setup do # Used as secret in generating nonce to prevent tampering of timestamp @secret = "session_options_secret" - @old_secret, ActionController::Base.session_options[:secret] = ActionController::Base.session_options[:secret], @secret + @controller.config.secret = @secret + # @old_secret, ActionController::Base.config.secret[:secret] = ActionController::Base.session_options[:secret], @secret end teardown do - ActionController::Base.session_options[:secret] = @old_secret + # ActionController::Base.session_options[:secret] = @old_secret end AUTH_HEADERS.each do |header| -- cgit v1.2.3 From ff29606c061099f82668ab62e50660cda8645512 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Thu, 4 Mar 2010 16:50:57 -0800 Subject: Refactor cache_store to use ActionController config --- actionpack/test/controller/caching_test.rb | 21 ++++++++++++++------- actionpack/test/controller/log_subscriber_test.rb | 3 +-- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index e42ef85b98..11ef3cdd92 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -6,12 +6,18 @@ CACHE_DIR = 'test_cache' # Don't change '/../temp/' cavalierly or you might hose something you don't want hosed FILE_STORE_PATH = File.join(File.dirname(__FILE__), '/../temp/', CACHE_DIR) ActionController::Base.page_cache_directory = FILE_STORE_PATH -ActionController::Base.cache_store = :file_store, FILE_STORE_PATH -class PageCachingTestController < ActionController::Base +class CachingController < ActionController::Base + abstract! + + self.cache_store = :file_store, FILE_STORE_PATH +end + +class PageCachingTestController < CachingController caches_page :ok, :no_content, :if => Proc.new { |c| !c.request.format.json? } caches_page :found, :not_found + def ok head :ok end @@ -55,6 +61,7 @@ class PageCachingTest < ActionController::TestCase @response = ActionController::TestResponse.new @controller = PageCachingTestController.new + @controller.cache_store = :file_store, FILE_STORE_PATH @params = {:controller => 'posts', :action => 'index', :only_path => true, :skip_relative_url_root => true} @rewriter = ActionController::UrlRewriter.new(@request, @params) @@ -148,7 +155,7 @@ class PageCachingTest < ActionController::TestCase end end -class ActionCachingTestController < ActionController::Base +class ActionCachingTestController < CachingController rescue_from(Exception) { head 500 } if defined? ActiveRecord rescue_from(ActiveRecord::RecordNotFound) { head :not_found } @@ -522,7 +529,7 @@ class ActionCacheTest < ActionController::TestCase end end -class FragmentCachingTestController < ActionController::Base +class FragmentCachingTestController < CachingController def some_action; end; end @@ -531,8 +538,8 @@ class FragmentCachingTest < ActionController::TestCase super ActionController::Base.perform_caching = true @store = ActiveSupport::Cache::MemoryStore.new - ActionController::Base.cache_store = @store @controller = FragmentCachingTestController.new + @controller.cache_store = @store @params = {:controller => 'posts', :action => 'index'} @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @@ -630,7 +637,7 @@ class FragmentCachingTest < ActionController::TestCase end -class FunctionalCachingController < ActionController::Base +class FunctionalCachingController < CachingController def fragment_cached end @@ -664,8 +671,8 @@ class FunctionalFragmentCachingTest < ActionController::TestCase super ActionController::Base.perform_caching = true @store = ActiveSupport::Cache::MemoryStore.new - ActionController::Base.cache_store = @store @controller = FunctionalCachingController.new + @controller.cache_store = @store @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb index 1f8134822c..20d3e77b6e 100644 --- a/actionpack/test/controller/log_subscriber_test.rb +++ b/actionpack/test/controller/log_subscriber_test.rb @@ -46,8 +46,7 @@ class ACLogSubscriberTest < ActionController::TestCase @cache_path = File.expand_path('../temp/test_cache', File.dirname(__FILE__)) ActionController::Base.page_cache_directory = @cache_path - ActionController::Base.cache_store = :file_store, @cache_path - + @controller.cache_store = :file_store, @cache_path Rails::LogSubscriber.add(:action_controller, ActionController::Railties::LogSubscriber.new) end -- cgit v1.2.3 From 900a2d304a83bad7a3958464b8dfa6fb49670686 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Thu, 4 Mar 2010 17:43:46 -0800 Subject: Get rid of relative_url_path in favor of respecting SCRIPT_NAME. Also added a way to specify a default SCRIPT_NAME when generating URLs out of the context of a request. --- actionpack/test/controller/url_for_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb index 07809aa480..fc7773dffe 100644 --- a/actionpack/test/controller/url_for_test.rb +++ b/actionpack/test/controller/url_for_test.rb @@ -118,7 +118,7 @@ module AbstractController add_host! assert_equal('https://www.basecamphq.com/subdir/c/a/i', - W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https', :relative_url_root => '/subdir') + W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https', :script_name => '/subdir') ) end @@ -153,7 +153,7 @@ module AbstractController controller = kls.new assert_equal 'http://www.basecamphq.com/subdir/home/sweet/home/again', - controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again', :relative_url_root => "/subdir") + controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again', :script_name => "/subdir") end end -- cgit v1.2.3 From 8f082ff4217175f52234f2223658619a9c923afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 8 Mar 2010 23:13:24 +0100 Subject: Clean LookupContext API. --- actionpack/test/controller/render_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index ecfe14b797..e3c4869391 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -355,7 +355,7 @@ class TestController < ActionController::Base @before = "i'm before the render" render_to_string :text => "foo" @after = "i'm after the render" - render :action => "test/hello_world" + render :template => "test/hello_world" end def render_to_string_with_exception @@ -369,7 +369,7 @@ class TestController < ActionController::Base rescue end @after = "i'm after the render" - render :action => "test/hello_world" + render :template => "test/hello_world" end def accessing_params_in_template_with_layout @@ -514,7 +514,7 @@ class TestController < ActionController::Base def render_to_string_with_partial @partial_only = render_to_string :partial => "partial_only" @partial_with_locals = render_to_string :partial => "customer", :locals => { :customer => Customer.new("david") } - render :action => "test/hello_world" + render :template => "test/hello_world" end def partial_with_counter -- cgit v1.2.3 From c507e16dba844c7b066d145bfd5c5d23e7a9c5ad Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 8 Mar 2010 21:40:04 -0800 Subject: Reinstate default_url_options and remove url_options= writer --- actionpack/test/controller/base_test.rb | 42 +++++++++++++++------------------ 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index ade9a7fcba..3e9f8ae048 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -181,7 +181,7 @@ class UrlOptionsTest < ActionController::TestCase rescue_action_in_public! end - def test_default_url_options_are_used_if_set + def test_url_options_override with_routing do |set| set.draw do |map| match 'from_view', :to => 'url_options#from_view', :as => :from_view @@ -206,20 +206,18 @@ class DefaultUrlOptionsTest < ActionController::TestCase rescue_action_in_public! end - def test_default_url_options_are_used_if_set + def test_default_url_options_override with_routing do |set| set.draw do |map| match 'from_view', :to => 'default_url_options#from_view', :as => :from_view match ':controller/:action' end - assert_deprecated do - get :from_view, :route => "from_view_url" + get :from_view, :route => "from_view_url" - assert_equal 'http://www.override.com/from_view?locale=en', @response.body - assert_equal 'http://www.override.com/from_view?locale=en', @controller.send(:from_view_url) - assert_equal 'http://www.override.com/default_url_options/new?locale=en', @controller.url_for(:controller => 'default_url_options') - end + assert_equal 'http://www.override.com/from_view?locale=en', @response.body + assert_equal 'http://www.override.com/from_view?locale=en', @controller.send(:from_view_url) + assert_equal 'http://www.override.com/default_url_options/new?locale=en', @controller.url_for(:controller => 'default_url_options') end end @@ -232,21 +230,19 @@ class DefaultUrlOptionsTest < ActionController::TestCase match ':controller/:action' end - assert_deprecated do - get :from_view, :route => "description_path(1)" - - assert_equal '/en/descriptions/1', @response.body - assert_equal '/en/descriptions', @controller.send(:descriptions_path) - assert_equal '/pl/descriptions', @controller.send(:descriptions_path, "pl") - assert_equal '/pl/descriptions', @controller.send(:descriptions_path, :locale => "pl") - assert_equal '/pl/descriptions.xml', @controller.send(:descriptions_path, "pl", "xml") - assert_equal '/en/descriptions.xml', @controller.send(:descriptions_path, :format => "xml") - assert_equal '/en/descriptions/1', @controller.send(:description_path, 1) - assert_equal '/pl/descriptions/1', @controller.send(:description_path, "pl", 1) - assert_equal '/pl/descriptions/1', @controller.send(:description_path, 1, :locale => "pl") - assert_equal '/pl/descriptions/1.xml', @controller.send(:description_path, "pl", 1, "xml") - assert_equal '/en/descriptions/1.xml', @controller.send(:description_path, 1, :format => "xml") - end + get :from_view, :route => "description_path(1)" + + assert_equal '/en/descriptions/1', @response.body + assert_equal '/en/descriptions', @controller.send(:descriptions_path) + assert_equal '/pl/descriptions', @controller.send(:descriptions_path, "pl") + assert_equal '/pl/descriptions', @controller.send(:descriptions_path, :locale => "pl") + assert_equal '/pl/descriptions.xml', @controller.send(:descriptions_path, "pl", "xml") + assert_equal '/en/descriptions.xml', @controller.send(:descriptions_path, :format => "xml") + assert_equal '/en/descriptions/1', @controller.send(:description_path, 1) + assert_equal '/pl/descriptions/1', @controller.send(:description_path, "pl", 1) + assert_equal '/pl/descriptions/1', @controller.send(:description_path, 1, :locale => "pl") + assert_equal '/pl/descriptions/1.xml', @controller.send(:description_path, "pl", 1, "xml") + assert_equal '/en/descriptions/1.xml', @controller.send(:description_path, 1, :format => "xml") end end -- cgit v1.2.3 From de79525d045b6ea2d83f325bdeeb9380510d045c Mon Sep 17 00:00:00 2001 From: wycats Date: Mon, 8 Mar 2010 21:08:31 -0800 Subject: Get rid of the instance-level URL rewriter --- actionpack/test/controller/caching_test.rb | 2 +- actionpack/test/controller/url_rewriter_test.rb | 44 +++++++++---------------- 2 files changed, 16 insertions(+), 30 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 11ef3cdd92..2be91893d4 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -64,7 +64,7 @@ class PageCachingTest < ActionController::TestCase @controller.cache_store = :file_store, FILE_STORE_PATH @params = {:controller => 'posts', :action => 'index', :only_path => true, :skip_relative_url_root => true} - @rewriter = ActionController::UrlRewriter.new(@request, @params) + @rewriter = ActionController::UrlRewriter FileUtils.rm_rf(File.dirname(FILE_STORE_PATH)) FileUtils.mkdir_p(FILE_STORE_PATH) diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb index 199b824a7a..3bc8bec3fb 100644 --- a/actionpack/test/controller/url_rewriter_test.rb +++ b/actionpack/test/controller/url_rewriter_test.rb @@ -4,10 +4,24 @@ require 'controller/fake_controllers' ActionController::UrlRewriter class UrlRewriterTests < ActionController::TestCase + class Rewriter + def initialize(request) + @options = { + :host => request.host_with_port, + :protocol => request.protocol + } + end + + def rewrite(router, options) + options = @options.merge(options) + ActionController::UrlRewriter.rewrite(router, options) + end + end + def setup @request = ActionController::TestRequest.new @params = {} - @rewriter = ActionController::UrlRewriter.new(@request, @params) + @rewriter = Rewriter.new(@request) #.new(@request, @params) end def test_port @@ -61,34 +75,6 @@ class UrlRewriterTests < ActionController::TestCase ) end - def test_overwrite_params - @params[:controller] = 'hi' - @params[:action] = 'bye' - @params[:id] = '2' - - assert_equal '/hi/hi/2', @rewriter.rewrite(@router, :only_path => true, :overwrite_params => {:action => 'hi'}) - u = @rewriter.rewrite(@router, :only_path => false, :overwrite_params => {:action => 'hi'}) - assert_match %r(/hi/hi/2$), u - end - - def test_overwrite_removes_original - @params[:controller] = 'search' - @params[:action] = 'list' - @params[:list_page] = 1 - - assert_equal '/search/list?list_page=2', @rewriter.rewrite(@router, :only_path => true, :overwrite_params => {"list_page" => 2}) - u = @rewriter.rewrite(@router, :only_path => false, :overwrite_params => {:list_page => 2}) - assert_equal 'http://test.host/search/list?list_page=2', u - end - - def test_to_str - @params[:controller] = 'hi' - @params[:action] = 'bye' - @request.parameters[:id] = '2' - - assert_equal 'http://, test.host, /, hi, bye, {"id"=>"2"}', @rewriter.to_str - end - def test_trailing_slash options = {:controller => 'foo', :action => 'bar', :id => '3', :only_path => true} assert_equal '/foo/bar/3', @rewriter.rewrite(@router, options) -- cgit v1.2.3 From ea4f8ef33f08a69a68f6b95f392e63ea9cc13602 Mon Sep 17 00:00:00 2001 From: Justin Ko Date: Tue, 9 Mar 2010 16:37:46 -0200 Subject: Reinstate dom_id in controllers. [#3040 state:committed] Signed-off-by: Santiago Pastorino Signed-off-by: Jeremy Kemper --- actionpack/test/controller/base_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index 3e9f8ae048..f047e7da30 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -76,6 +76,9 @@ class UrlOptionsController < ActionController::Base end end +class RecordIdentifierController < ActionController::Base +end + class ControllerClassTests < ActiveSupport::TestCase def test_controller_path assert_equal 'empty', EmptyController.controller_path @@ -102,6 +105,11 @@ class ControllerClassTests < ActiveSupport::TestCase assert_equal [:password], parameters end + + def test_record_identifier + assert_respond_to RecordIdentifierController.new, :dom_id + assert_respond_to RecordIdentifierController.new, :dom_class + end end class ControllerInstanceTests < Test::Unit::TestCase -- cgit v1.2.3 From 7db80f87e9c194713c2016820e39af6043ddf8d0 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 9 Mar 2010 20:50:35 -0600 Subject: Move AC::UrlRewriter onto route set --- actionpack/test/controller/caching_test.rb | 5 ++--- actionpack/test/controller/url_rewriter_test.rb | 5 +---- 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 2be91893d4..08efd5a48c 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -64,7 +64,6 @@ class PageCachingTest < ActionController::TestCase @controller.cache_store = :file_store, FILE_STORE_PATH @params = {:controller => 'posts', :action => 'index', :only_path => true, :skip_relative_url_root => true} - @rewriter = ActionController::UrlRewriter FileUtils.rm_rf(File.dirname(FILE_STORE_PATH)) FileUtils.mkdir_p(FILE_STORE_PATH) @@ -82,9 +81,9 @@ class PageCachingTest < ActionController::TestCase match '/', :to => 'posts#index', :as => :main end @params[:format] = 'rss' - assert_equal '/posts.rss', @rewriter.rewrite(@router, @params) + assert_equal '/posts.rss', @router.rewrite(@params) @params[:format] = nil - assert_equal '/', @rewriter.rewrite(@router, @params) + assert_equal '/', @router.rewrite(@params) end end diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb index 3bc8bec3fb..cf775846df 100644 --- a/actionpack/test/controller/url_rewriter_test.rb +++ b/actionpack/test/controller/url_rewriter_test.rb @@ -1,8 +1,6 @@ require 'abstract_unit' require 'controller/fake_controllers' -ActionController::UrlRewriter - class UrlRewriterTests < ActionController::TestCase class Rewriter def initialize(request) @@ -13,8 +11,7 @@ class UrlRewriterTests < ActionController::TestCase end def rewrite(router, options) - options = @options.merge(options) - ActionController::UrlRewriter.rewrite(router, options) + router.rewrite(@options.merge(options)) end end -- cgit v1.2.3 From 4d2470f7daad8cebd0a69f5ea0509a41af0596b8 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 9 Mar 2010 21:00:24 -0600 Subject: RouteSet#rewrite => url_for --- actionpack/test/controller/caching_test.rb | 4 ++-- actionpack/test/controller/url_rewriter_test.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 08efd5a48c..8a0c118d3c 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -81,9 +81,9 @@ class PageCachingTest < ActionController::TestCase match '/', :to => 'posts#index', :as => :main end @params[:format] = 'rss' - assert_equal '/posts.rss', @router.rewrite(@params) + assert_equal '/posts.rss', @router.url_for(@params) @params[:format] = nil - assert_equal '/', @router.rewrite(@params) + assert_equal '/', @router.url_for(@params) end end diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb index cf775846df..7b46a48a1d 100644 --- a/actionpack/test/controller/url_rewriter_test.rb +++ b/actionpack/test/controller/url_rewriter_test.rb @@ -11,7 +11,7 @@ class UrlRewriterTests < ActionController::TestCase end def rewrite(router, options) - router.rewrite(@options.merge(options)) + router.url_for(@options.merge(options)) end end -- cgit v1.2.3 From dcd110c724aa5111e67e7264e6bc76ebdda6d50f Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 9 Mar 2010 21:25:09 -0600 Subject: skip_relative_url_root url_for option is dead --- actionpack/test/controller/caching_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 8a0c118d3c..a3c8fdbb6e 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -63,7 +63,7 @@ class PageCachingTest < ActionController::TestCase @controller = PageCachingTestController.new @controller.cache_store = :file_store, FILE_STORE_PATH - @params = {:controller => 'posts', :action => 'index', :only_path => true, :skip_relative_url_root => true} + @params = {:controller => 'posts', :action => 'index', :only_path => true} FileUtils.rm_rf(File.dirname(FILE_STORE_PATH)) FileUtils.mkdir_p(FILE_STORE_PATH) -- cgit v1.2.3 From 6c027443b044276fd2a85b387b67a8dee940b320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 11 Mar 2010 12:45:05 +0100 Subject: Add tests for lookup context. --- actionpack/test/controller/new_base/render_rjs_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/new_base/render_rjs_test.rb b/actionpack/test/controller/new_base/render_rjs_test.rb index 8c47b38ab6..f4516ade63 100644 --- a/actionpack/test/controller/new_base/render_rjs_test.rb +++ b/actionpack/test/controller/new_base/render_rjs_test.rb @@ -17,7 +17,7 @@ module RenderRjs end def index_locale - old_locale, I18n.locale = I18n.locale, :da + self.locale = :da end end -- cgit v1.2.3