From ea2336b9e2c47a9cc1a73b1350ffc03252e6468e Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Thu, 21 Mar 2013 14:23:46 -0400 Subject: failure to parse params should trigger a 400 Bad Request --- actionpack/lib/action_dispatch/middleware/exception_wrapper.rb | 1 + actionpack/test/dispatch/show_exceptions_test.rb | 6 ++++++ actionpack/test/fixtures/public/400.html | 1 + 3 files changed, 8 insertions(+) create mode 100644 actionpack/test/fixtures/public/400.html (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb b/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb index 7489ce8028..4c331f2f0b 100644 --- a/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb +++ b/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb @@ -12,6 +12,7 @@ module ActionDispatch 'ActionController::NotImplemented' => :not_implemented, 'ActionController::UnknownFormat' => :not_acceptable, 'ActionController::InvalidAuthenticityToken' => :unprocessable_entity, + 'ActionDispatch::ParamsParser::ParseError' => :bad_request, 'ActionController::BadRequest' => :bad_request, 'ActionController::ParameterMissing' => :bad_request ) diff --git a/actionpack/test/dispatch/show_exceptions_test.rb b/actionpack/test/dispatch/show_exceptions_test.rb index 45f8fc11b3..900f45ee5e 100644 --- a/actionpack/test/dispatch/show_exceptions_test.rb +++ b/actionpack/test/dispatch/show_exceptions_test.rb @@ -8,6 +8,8 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest case req.path when "/not_found" raise AbstractController::ActionNotFound + when "/bad_params" + raise ActionDispatch::ParamsParser::ParseError.new("", StandardError.new) when "/method_not_allowed" raise ActionController::MethodNotAllowed when "/not_found_original_exception" @@ -33,6 +35,10 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest get "/", {}, {'action_dispatch.show_exceptions' => true} assert_response 500 assert_equal "500 error fixture\n", body + + get "/bad_params", {}, {'action_dispatch.show_exceptions' => true} + assert_response 400 + assert_equal "400 error fixture\n", body get "/not_found", {}, {'action_dispatch.show_exceptions' => true} assert_response 404 diff --git a/actionpack/test/fixtures/public/400.html b/actionpack/test/fixtures/public/400.html new file mode 100644 index 0000000000..03be6bedaf --- /dev/null +++ b/actionpack/test/fixtures/public/400.html @@ -0,0 +1 @@ +400 error fixture -- cgit v1.2.3 From e9eb30fae4f0a9645bcc258fa515182a29e72998 Mon Sep 17 00:00:00 2001 From: Rncrtr Date: Thu, 18 Apr 2013 14:25:27 -0600 Subject: fixed typo in select_tag docs --- actionpack/lib/action_view/helpers/form_tag_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 8abd5d6e9c..c10566a87d 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -81,7 +81,7 @@ module ActionView # ==== Options # * :multiple - If set to true the selection will allow multiple choices. # * :disabled - If set to true, the user will not be able to use this input. - # * :include_blank - If set to true, an empty option will be create + # * :include_blank - If set to true, an empty option will be created. # * :prompt - Create a prompt option with blank value and the text asking user to select something # * Any other key creates standard HTML attributes for the tag. # -- cgit v1.2.3 From 6d2a77ea0d3a5db1cc1195df7429d0043c775896 Mon Sep 17 00:00:00 2001 From: Gaurish Sharma Date: Tue, 30 Apr 2013 23:11:17 +0530 Subject: Rack::Mount was replaced by Journey, Fixed comment --- actionpack/lib/action_dispatch/routing/mapper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 1611812ab4..c3fd0c18ec 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -299,7 +299,7 @@ module ActionDispatch end end - # Invokes Rack::Mount::Utils.normalize path and ensure that + # Invokes Journey::Router::Utils.normalize_path and ensure that # (:locale) becomes (/:locale) instead of /(:locale). Except # for root cases, where the latter is the correct one. def self.normalize_path(path) -- cgit v1.2.3 From 78701a82ef7732bf4ebfeca4e264120bb051b425 Mon Sep 17 00:00:00 2001 From: Ben Holley Date: Tue, 30 Apr 2013 13:43:59 -0500 Subject: add missing semicolon to journey parser.y --- actionpack/lib/action_dispatch/journey/parser.y | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/journey/parser.y b/actionpack/lib/action_dispatch/journey/parser.y index a2e1afed32..040f8d5922 100644 --- a/actionpack/lib/action_dispatch/journey/parser.y +++ b/actionpack/lib/action_dispatch/journey/parser.y @@ -36,6 +36,7 @@ rule ; literal : LITERAL { result = Literal.new(val.first) } + ; dot : DOT { result = Dot.new(val.first) } ; -- cgit v1.2.3 From 630d2e4e38f06b3998c663aa3e3bbd554ec2a78b Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 1 May 2013 10:48:01 -0300 Subject: Fix failing AP test --- actionpack/test/dispatch/request/json_params_parsing_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/test/dispatch/request/json_params_parsing_test.rb b/actionpack/test/dispatch/request/json_params_parsing_test.rb index 7d3fc84089..8d0a845f15 100644 --- a/actionpack/test/dispatch/request/json_params_parsing_test.rb +++ b/actionpack/test/dispatch/request/json_params_parsing_test.rb @@ -50,7 +50,7 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest output = StringIO.new json = "[\"person]\": {\"name\": \"David\"}}" post "/parse", json, {'CONTENT_TYPE' => 'application/json', 'action_dispatch.show_exceptions' => true, 'action_dispatch.logger' => ActiveSupport::Logger.new(output)} - assert_response :error + assert_response :bad_request output.rewind && err = output.read assert err =~ /Error occurred while parsing request parameters/ end -- cgit v1.2.3 From b0f1cd8719c2c75ebeddb376312fa4bf8c1c9c22 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Thu, 2 May 2013 04:45:47 +0500 Subject: use constant for encoding --- actionpack/lib/action_dispatch/http/parameters.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/http/parameters.rb b/actionpack/lib/action_dispatch/http/parameters.rb index 246d9c121a..20c24ddd85 100644 --- a/actionpack/lib/action_dispatch/http/parameters.rb +++ b/actionpack/lib/action_dispatch/http/parameters.rb @@ -65,7 +65,7 @@ module ActionDispatch new_hash = {} params.each do |k, v| - new_key = k.is_a?(String) ? k.dup.force_encoding("UTF-8").encode! : k + new_key = k.is_a?(String) ? k.dup.force_encoding(Encoding::UTF_8).encode! : k new_hash[new_key] = case v when Hash -- cgit v1.2.3 From 3bd887da9ffe0555c752380c41a4c937867635b2 Mon Sep 17 00:00:00 2001 From: Tim Krajcar Date: Thu, 2 May 2013 09:43:23 -0700 Subject: Add styling to h1 --- .../lib/action_dispatch/middleware/templates/rescues/layout.erb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb b/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb index 891c87ac27..bc5d03dc10 100644 --- a/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb +++ b/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb @@ -34,6 +34,12 @@ padding: 0.5em 1.5em; } + h1 { + margin: 0.2em 0; + line-height: 1.1em; + font-size: 2em; + } + h2 { color: #C52F24; line-height: 25px; -- cgit v1.2.3 From 9a4268db99d93190c58bddcb150832727a0d5129 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 3 May 2013 16:42:31 +0200 Subject: Fix generating route from engine to other engine A regression was introduced in 5b3bb6, generating route from within an engine to an another engine resulted in prefixing a path with the SCRIPT_NAME value. The regression was caused by the fact that SCRIPT_NAME should be appended only if it's the SCRIPT_NAME for the application, not if it's SCRIPT_NAME from the current engine. closes #10409 --- actionpack/lib/action_controller/metal/url_for.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_controller/metal/url_for.rb b/actionpack/lib/action_controller/metal/url_for.rb index 505f3b4e61..754249cbc8 100644 --- a/actionpack/lib/action_controller/metal/url_for.rb +++ b/actionpack/lib/action_controller/metal/url_for.rb @@ -32,7 +32,8 @@ module ActionController if (same_origin = _routes.equal?(env["action_dispatch.routes"])) || (script_name = env["ROUTES_#{_routes.object_id}_SCRIPT_NAME"]) || - (original_script_name = env['SCRIPT_NAME']) + (original_script_name = env['ORIGINAL_SCRIPT_NAME']) + @_url_options.dup.tap do |options| if original_script_name options[:original_script_name] = original_script_name -- cgit v1.2.3 From 473a60be3d4aa7ea38277aef51ef47a288f9974e Mon Sep 17 00:00:00 2001 From: Vladimir Strakhov Date: Sun, 5 May 2013 14:24:06 +0400 Subject: Added missing `require` to ActionView::LookupContext --- actionpack/lib/action_view/lookup_context.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/lookup_context.rb b/actionpack/lib/action_view/lookup_context.rb index d61cc0f304..f9d5b97fe3 100644 --- a/actionpack/lib/action_view/lookup_context.rb +++ b/actionpack/lib/action_view/lookup_context.rb @@ -1,5 +1,6 @@ require 'thread_safe' require 'active_support/core_ext/module/remove_method' +require 'active_support/core_ext/module/attribute_accessors' module ActionView # = Action View Lookup Context -- cgit v1.2.3 From a145955fb7a7c3963453733b3fbac8a2c12a45d7 Mon Sep 17 00:00:00 2001 From: Lance Ivy Date: Sun, 5 May 2013 14:18:03 -0400 Subject: use canonical #controller_path logic in controller test cases --- actionpack/lib/action_controller/test_case.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 41a286f0ed..e5f1ad63c2 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -558,7 +558,7 @@ module ActionController parameters ||= {} controller_class_name = @controller.class.anonymous? ? "anonymous" : - @controller.class.name.underscore.sub(/_controller$/, '') + @controller.class.controller_path @request.assign_parameters(@routes, controller_class_name, action.to_s, parameters) -- cgit v1.2.3 From 47bf072330f4b62a125d7e93b8a11c8d92c84387 Mon Sep 17 00:00:00 2001 From: Junya Ogura Date: Mon, 6 May 2013 06:15:08 +0900 Subject: Fix typo in documentation comment --- actionpack/lib/action_view/helpers/asset_tag_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 693b6bdfcc..3a6f449eb8 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -155,7 +155,7 @@ module ActionView # ==== Examples # # favicon_link_tag '/myicon.ico' - # # => + # # => # # Mobile Safari looks for a different tag, pointing to an image that # will be used if you add the page to the home screen of an iPod Touch, iPhone, or iPad. -- cgit v1.2.3 From d6b9e8e9319f2a568224456e3e15759b76581eed Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Fri, 3 May 2013 14:28:16 +0200 Subject: Instrument template compilation --- actionpack/lib/action_view/template.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index 946db1df79..ebbc1c79d6 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -138,7 +138,7 @@ module ActionView # we use a bang in this instrumentation because you don't want to # consume this in production. This is only slow if it's being listened to. def render(view, locals, buffer=nil, &block) - ActiveSupport::Notifications.instrument("!render_template.action_view", virtual_path: @virtual_path, identifier: @identifier) do + instrument("!render_template") do compile!(view) view.send(method_name, locals, buffer, &block) end @@ -245,7 +245,9 @@ module ActionView mod = view.singleton_class end - compile(view, mod) + instrument("!compile_template") do + compile(view, mod) + end # Just discard the source if we have a virtual path. This # means we can get the template back. @@ -335,5 +337,10 @@ module ActionView def identifier_method_name #:nodoc: inspect.gsub(/[^a-z_]/, '_') end + + def instrument(action, &block) + payload = { virtual_path: @virtual_path, identifier: @identifier } + ActiveSupport::Notifications.instrument("#{action}.action_view", payload, &block) + end end end -- cgit v1.2.3 From 584ebed482907abb3b18c65495cd62fe5f643a89 Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Mon, 6 May 2013 23:25:05 +0530 Subject: remove unused variable --- actionpack/lib/action_view/helpers/form_options_helper.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb index 719c9c09b5..ad26505086 100644 --- a/actionpack/lib/action_view/helpers/form_options_helper.rb +++ b/actionpack/lib/action_view/helpers/form_options_helper.rb @@ -515,7 +515,6 @@ module ActionView divider = options[:divider] else prompt = options - options = {} message = "Passing the prompt to grouped_options_for_select as an argument is deprecated. " \ "Please use an options hash like `{ prompt: #{prompt.inspect} }`." ActiveSupport::Deprecation.warn message -- cgit v1.2.3 From 3073c531983de243219fb55be93fbcebfdd9c44e Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Mon, 6 May 2013 17:38:45 -0700 Subject: Updates to make rails 4 happy with minitest 5: + Namespace changes, overhaul of runners. + Internal ivar name changes - Removed a logger globally applied to tests that spew everywhere?!? + Override Minitest#__run to sort tests by name. + Reworked testing isolation to work with the new cleaner architecture. - Removed a bunch of tests that just test minitest straight up. I think these changes were all merged to minitest 4 a long time ago. - Minor report output differences. --- actionpack/lib/action_view/test_case.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb index 10b487f37a..3145446114 100644 --- a/actionpack/lib/action_view/test_case.rb +++ b/actionpack/lib/action_view/test_case.rb @@ -211,7 +211,9 @@ module ActionView alias_method :_view, :view INTERNAL_IVARS = [ - :@__name__, + :@NAME, + :@failures, + :@assertions, :@__io__, :@_assertion_wrapped, :@_assertions, -- cgit v1.2.3 From 3c516c4b5278c27d55425f7c2f875ca1cd2e8511 Mon Sep 17 00:00:00 2001 From: Bryan Ricker Date: Mon, 29 Apr 2013 15:42:16 -0700 Subject: Allow numbers in partial name for digesting Add failing test for template with number at the end Use \w for RENDER_DEPENDENCY regex Spacing Add CHANGELOG entry --- actionpack/CHANGELOG.md | 4 +++- actionpack/lib/action_view/dependency_tracker.rb | 2 +- actionpack/test/fixtures/digestor/messages/show.html.erb | 3 ++- actionpack/test/template/digestor_test.rb | 6 ++++++ 4 files changed, 12 insertions(+), 3 deletions(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index ffafa7412d..6f5027dc23 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,3 +1,5 @@ -* No changes. +* Fix an issue where partials with a number in the filename weren't being digested for cache dependencies. + + *Bryan Ricker* Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/actionpack/CHANGELOG.md) for previous changes. diff --git a/actionpack/lib/action_view/dependency_tracker.rb b/actionpack/lib/action_view/dependency_tracker.rb index a2a555dfcb..45d17be605 100644 --- a/actionpack/lib/action_view/dependency_tracker.rb +++ b/actionpack/lib/action_view/dependency_tracker.rb @@ -39,7 +39,7 @@ module ActionView render\s* # render, followed by optional whitespace \(? # start an optional parenthesis for the render call (partial:|:partial\s+=>)?\s* # naming the partial, used with collection -- 1st capture - ([@a-z"'][@a-z_\/\."']+) # the template name itself -- 2nd capture + ([@a-z"'][@\w\/\."']+) # the template name itself -- 2nd capture /x def self.call(name, template) diff --git a/actionpack/test/fixtures/digestor/messages/show.html.erb b/actionpack/test/fixtures/digestor/messages/show.html.erb index 51b3b61e8e..130e67109e 100644 --- a/actionpack/test/fixtures/digestor/messages/show.html.erb +++ b/actionpack/test/fixtures/digestor/messages/show.html.erb @@ -7,7 +7,8 @@ <%= render @message.history.events %> <%# render "something_missing" %> +<%# render "something_missing_1" %> <% # Template Dependency: messages/form -%> \ No newline at end of file +%> diff --git a/actionpack/test/template/digestor_test.rb b/actionpack/test/template/digestor_test.rb index e29cecabc0..06735c30d3 100644 --- a/actionpack/test/template/digestor_test.rb +++ b/actionpack/test/template/digestor_test.rb @@ -83,6 +83,12 @@ class TemplateDigestorTest < ActionView::TestCase end end + def test_logging_of_missing_template_ending_with_number + assert_logged "Couldn't find template for digesting: messages/something_missing_1.html" do + digest("messages/show") + end + end + def test_nested_template_directory assert_digest_difference("messages/show") do change_template("messages/actions/_move") -- cgit v1.2.3 From ca0275d36b395631725c4583db5a45c06443fdb9 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Tue, 7 May 2013 08:37:20 -0400 Subject: Test that #fresh_when accepts an array https://github.com/rails/etagger/pull/3 --- actionpack/test/controller/render_test.rb | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 0e5bad7482..72411ec900 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -32,6 +32,10 @@ class TestControllerWithExtraEtags < ActionController::Base def fresh render text: "stale" if stale?(etag: '123') end + + def array + render text: "stale" if stale?(etag: %w(1 2 3)) + end end class TestController < ActionController::Base @@ -1649,7 +1653,6 @@ class LastModifiedRenderTest < ActionController::TestCase assert_equal @last_modified, @response.headers['Last-Modified'] end - def test_request_with_bang_gets_last_modified get :conditional_hello_with_bangs assert_equal @last_modified, @response.headers['Last-Modified'] @@ -1678,7 +1681,7 @@ class EtagRenderTest < ActionController::TestCase end def test_multiple_etags - @request.if_none_match = %("#{Digest::MD5.hexdigest(ActiveSupport::Cache.expand_cache_key([ "123", 'ab', :cde, [:f] ]))}") + @request.if_none_match = etag(["123", 'ab', :cde, [:f]]) get :fresh assert_response :not_modified @@ -1686,6 +1689,20 @@ class EtagRenderTest < ActionController::TestCase get :fresh assert_response :success end + + def test_array + @request.if_none_match = etag([%w(1 2 3), 'ab', :cde, [:f]]) + get :array + assert_response :not_modified + + @request.if_none_match = %("nomatch") + get :array + assert_response :success + end + + def etag(record) + Digest::MD5.hexdigest(ActiveSupport::Cache.expand_cache_key(record)).inspect + end end -- cgit v1.2.3 From 5e03239d59db7b21ceda576ce52b7fab3ad58c2d Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 8 May 2013 21:28:27 -0700 Subject: Fix that JSON and XML exception responses should give the HTTP error message for their status, by default, not the message from the underlying exception --- actionpack/lib/action_dispatch/middleware/public_exceptions.rb | 4 ++-- actionpack/test/controller/show_exceptions_test.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/middleware/public_exceptions.rb b/actionpack/lib/action_dispatch/middleware/public_exceptions.rb index 53bedaa40a..ebbf91d5c4 100644 --- a/actionpack/lib/action_dispatch/middleware/public_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/public_exceptions.rb @@ -11,7 +11,7 @@ module ActionDispatch status = env["PATH_INFO"][1..-1] request = ActionDispatch::Request.new(env) content_type = request.formats.first - body = { :status => status, :error => exception.message } + body = { :status => status, :error => Rack::Utils::HTTP_STATUS_CODES.fetch(status.to_i, Rack::Utils::HTTP_STATUS_CODES[500]) } render(status, content_type, body) end @@ -19,7 +19,7 @@ module ActionDispatch private def render(status, content_type, body) - format = content_type && "to_#{content_type.to_sym}" + format = "to_#{content_type.to_sym}" if content_type if format && body.respond_to?(format) render_format(status, content_type, body.public_send(format)) else diff --git a/actionpack/test/controller/show_exceptions_test.rb b/actionpack/test/controller/show_exceptions_test.rb index 69bf4b7720..ff23b22040 100644 --- a/actionpack/test/controller/show_exceptions_test.rb +++ b/actionpack/test/controller/show_exceptions_test.rb @@ -75,7 +75,7 @@ module ShowExceptions get "/", {}, 'HTTP_ACCEPT' => 'application/json' assert_response :internal_server_error assert_equal 'application/json', response.content_type.to_s - assert_equal({ :status => '500', :error => 'boom!' }.to_json, response.body) + assert_equal({ :status => '500', :error => 'Internal Server Error' }.to_json, response.body) end def test_render_xml_exception @@ -83,7 +83,7 @@ module ShowExceptions get "/", {}, 'HTTP_ACCEPT' => 'application/xml' assert_response :internal_server_error assert_equal 'application/xml', response.content_type.to_s - assert_equal({ :status => '500', :error => 'boom!' }.to_xml, response.body) + assert_equal({ :status => '500', :error => 'Internal Server Error' }.to_xml, response.body) end def test_render_fallback_exception -- cgit v1.2.3 From 39b8b8fdbf6c175a64f07198ff1c950e33c72cd0 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Thu, 9 May 2013 17:27:08 +0530 Subject: rails -> Rails [ci skip] --- actionpack/lib/action_dispatch/journey/formatter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/journey/formatter.rb b/actionpack/lib/action_dispatch/journey/formatter.rb index a732e570f2..e288f026c7 100644 --- a/actionpack/lib/action_dispatch/journey/formatter.rb +++ b/actionpack/lib/action_dispatch/journey/formatter.rb @@ -3,7 +3,7 @@ require 'action_controller/metal/exceptions' module ActionDispatch module Journey # The Formatter class is used for formatting URLs. For example, parameters - # passed to +url_for+ in rails will eventually call Formatter#generate. + # passed to +url_for+ in Rails will eventually call Formatter#generate. class Formatter # :nodoc: attr_reader :routes -- cgit v1.2.3 From 7133b0090e7509025bf71f22fb9f41404031dbbf Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Thu, 9 May 2013 20:31:31 +0530 Subject: remove variable and fix warning --- actionpack/lib/action_dispatch/middleware/public_exceptions.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/middleware/public_exceptions.rb b/actionpack/lib/action_dispatch/middleware/public_exceptions.rb index ebbf91d5c4..cbb2d475b1 100644 --- a/actionpack/lib/action_dispatch/middleware/public_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/public_exceptions.rb @@ -7,7 +7,6 @@ module ActionDispatch end def call(env) - exception = env["action_dispatch.exception"] status = env["PATH_INFO"][1..-1] request = ActionDispatch::Request.new(env) content_type = request.formats.first -- cgit v1.2.3 From 690fd221c56bfec04cee9c94e8406b93203215ac Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Fri, 10 May 2013 11:21:58 +0530 Subject: sort => sort! on new array --- actionpack/lib/action_view/helpers/tag_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb index 8c7524e795..3939e4737b 100644 --- a/actionpack/lib/action_view/helpers/tag_helper.rb +++ b/actionpack/lib/action_view/helpers/tag_helper.rb @@ -148,7 +148,7 @@ module ActionView attrs << tag_option(key, value, escape) end end - " #{attrs.sort * ' '}".html_safe unless attrs.empty? + " #{attrs.sort! * ' '}".html_safe unless attrs.empty? end def data_tag_option(key, value, escape) -- cgit v1.2.3 From cd35c1909d44f3c033dc4efbc381d389a19aa2db Mon Sep 17 00:00:00 2001 From: Weston Platter Date: Tue, 7 May 2013 21:29:40 -0500 Subject: [ci skip] document protect_against_forgery? method --- actionpack/lib/action_controller/metal/request_forgery_protection.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack') diff --git a/actionpack/lib/action_controller/metal/request_forgery_protection.rb b/actionpack/lib/action_controller/metal/request_forgery_protection.rb index d275a854fd..573c739da4 100644 --- a/actionpack/lib/action_controller/metal/request_forgery_protection.rb +++ b/actionpack/lib/action_controller/metal/request_forgery_protection.rb @@ -199,6 +199,7 @@ module ActionController #:nodoc: params[request_forgery_protection_token] end + # Checks if the controller allows forgery protection. def protect_against_forgery? allow_forgery_protection end -- cgit v1.2.3 From ce4456fde6f45f1abd020cbdeb520d401299e01f Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Sat, 11 May 2013 13:59:37 -0700 Subject: Replace multi_json with json --- actionpack/test/dispatch/request/json_params_parsing_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/test/dispatch/request/json_params_parsing_test.rb b/actionpack/test/dispatch/request/json_params_parsing_test.rb index 8d0a845f15..b62ed6a8b2 100644 --- a/actionpack/test/dispatch/request/json_params_parsing_test.rb +++ b/actionpack/test/dispatch/request/json_params_parsing_test.rb @@ -62,7 +62,7 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest $stderr = StringIO.new # suppress the log json = "[\"person]\": {\"name\": \"David\"}}" exception = assert_raise(ActionDispatch::ParamsParser::ParseError) { post "/parse", json, {'CONTENT_TYPE' => 'application/json', 'action_dispatch.show_exceptions' => false} } - assert_equal MultiJson::DecodeError, exception.original_exception.class + assert_equal JSON::ParserError, exception.original_exception.class assert_equal exception.original_exception.message, exception.message ensure $stderr = STDERR -- cgit v1.2.3 From c43ca06ca091fc09e2c86bb051ac92b648f12b64 Mon Sep 17 00:00:00 2001 From: Julian Vargas Date: Sun, 12 May 2013 15:04:01 -0500 Subject: Code cleanup for ActionDispatch::Flash#call The nested `if` was replaced by using `presence` which takes account for the given hash when it is `nil` or when it is empty. The `else` was removed because what it was doing was to assign to `env[KEY]` the value it already had. --- actionpack/lib/action_dispatch/middleware/flash.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/middleware/flash.rb b/actionpack/lib/action_dispatch/middleware/flash.rb index 7e56feb90a..f8f9cf7c9f 100644 --- a/actionpack/lib/action_dispatch/middleware/flash.rb +++ b/actionpack/lib/action_dispatch/middleware/flash.rb @@ -243,15 +243,9 @@ module ActionDispatch session = Request::Session.find(env) || {} flash_hash = env[KEY] - if flash_hash - if !flash_hash.empty? || session.key?('flash') - session["flash"] = flash_hash.to_session_value - new_hash = flash_hash.dup - else - new_hash = flash_hash - end - - env[KEY] = new_hash + if flash_hash.present? || session.key?('flash') + session["flash"] = flash_hash.to_session_value + env[KEY] = flash_hash.dup end if (!session.respond_to?(:loaded?) || session.loaded?) && # (reset_session uses {}, which doesn't implement #loaded?) -- cgit v1.2.3 From d63e44c46116d9771adcae3e2c3fd23bbc535854 Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Mon, 13 May 2013 12:19:25 +0200 Subject: Fixing build broken by this change c43ca06ca091fc09e2c86bb051ac92b648f12b64 --- actionpack/lib/action_dispatch/middleware/flash.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/middleware/flash.rb b/actionpack/lib/action_dispatch/middleware/flash.rb index f8f9cf7c9f..89003e7a5e 100644 --- a/actionpack/lib/action_dispatch/middleware/flash.rb +++ b/actionpack/lib/action_dispatch/middleware/flash.rb @@ -243,13 +243,13 @@ module ActionDispatch session = Request::Session.find(env) || {} flash_hash = env[KEY] - if flash_hash.present? || session.key?('flash') + if flash_hash && (flash_hash.present? || session.key?('flash')) session["flash"] = flash_hash.to_session_value env[KEY] = flash_hash.dup end if (!session.respond_to?(:loaded?) || session.loaded?) && # (reset_session uses {}, which doesn't implement #loaded?) - session.key?('flash') && session['flash'].nil? + session.key?('flash') && session['flash'].nil? session.delete('flash') end end -- cgit v1.2.3 From 8da819eef5f11cc016ffa9ad747421ee50be32fa Mon Sep 17 00:00:00 2001 From: Angelo capilleri Date: Mon, 13 May 2013 10:38:34 +0200 Subject: add test for skip_before_filter with condition --- actionpack/test/controller/filters_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'actionpack') diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 3b79161ad3..b5f22066af 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -213,6 +213,14 @@ class FilterTest < ActionController::TestCase before_filter :clean_up_tmp, :if => Proc.new { |c| false } end + class ConditionalOptionsSkipFilter < ConditionalFilterController + before_filter :ensure_login + before_filter :clean_up_tmp + + skip_before_filter :ensure_login, if: -> { false } + skip_before_filter :clean_up_tmp, if: -> { true } + end + class PrependingController < TestController prepend_before_filter :wonderful_life # skip_before_filter :fire_flash @@ -593,6 +601,11 @@ class FilterTest < ActionController::TestCase assert_equal %w( ensure_login ), assigns["ran_filter"] end + def test_running_conditional_skip_options + test_process(ConditionalOptionsSkipFilter) + assert_equal %w( ensure_login ), assigns["ran_filter"] + end + def test_running_collection_condition_filters test_process(ConditionalCollectionFilterController) assert_equal %w( ensure_login ), assigns["ran_filter"] -- cgit v1.2.3 From 8ece52f731d3ae9dfc52033e3652b8f011632877 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 14 May 2013 14:11:03 -0700 Subject: use public api for testing rather than grabbing instance variables --- actionpack/test/controller/filters_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 3b79161ad3..e74bc2bb3d 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -10,7 +10,7 @@ class ActionController::Base def before_filters filters = _process_action_callbacks.select { |c| c.kind == :before } - filters.map! { |c| c.instance_variable_get(:@raw_filter) } + filters.map! { |c| c.raw_filter } end end -- cgit v1.2.3 From 4c628e48a56920877948bd9d69d3e3caa41b5da8 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 14 May 2013 14:13:32 -0700 Subject: inspect the filter when displaying error messages --- actionpack/lib/action_controller/log_subscriber.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_controller/log_subscriber.rb b/actionpack/lib/action_controller/log_subscriber.rb index 7318c8b7ec..9279d8bcea 100644 --- a/actionpack/lib/action_controller/log_subscriber.rb +++ b/actionpack/lib/action_controller/log_subscriber.rb @@ -33,7 +33,7 @@ module ActionController end def halted_callback(event) - info("Filter chain halted as #{event.payload[:filter]} rendered or redirected") + info("Filter chain halted as #{event.payload[:filter].inspect} rendered or redirected") end def send_file(event) -- cgit v1.2.3 From ba552764344bc0a3c25b8576ec11f127ceaa16da Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 14 May 2013 16:03:09 -0700 Subject: deprecating string based terminators --- actionpack/lib/abstract_controller/callbacks.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/abstract_controller/callbacks.rb b/actionpack/lib/abstract_controller/callbacks.rb index 599fff81c2..19cfd7dae1 100644 --- a/actionpack/lib/abstract_controller/callbacks.rb +++ b/actionpack/lib/abstract_controller/callbacks.rb @@ -8,7 +8,9 @@ module AbstractController include ActiveSupport::Callbacks included do - define_callbacks :process_action, :terminator => "response_body", :skip_after_callbacks_if_terminated => true + define_callbacks :process_action, + terminator: ->(controller,_) { controller.response_body }, + skip_after_callbacks_if_terminated: true end # Override AbstractController::Base's process_action to run the -- cgit v1.2.3 From 122ac9fd46d7c9ac198bf980df4f038247eb0ba5 Mon Sep 17 00:00:00 2001 From: Sean Walbran Date: Wed, 15 May 2013 09:07:46 -0500 Subject: restore ability to return nil from asset_host proc, add test --- actionpack/lib/action_view/helpers/asset_url_helper.rb | 3 ++- actionpack/test/template/asset_tag_helper_test.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/helpers/asset_url_helper.rb b/actionpack/lib/action_view/helpers/asset_url_helper.rb index 71b78cf0b5..b5f2df76ab 100644 --- a/actionpack/lib/action_view/helpers/asset_url_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_url_helper.rb @@ -193,7 +193,6 @@ module ActionView request = self.request if respond_to?(:request) host = config.asset_host if defined? config.asset_host host ||= request.base_url if request && options[:protocol] == :request - return unless host if host.respond_to?(:call) arity = host.respond_to?(:arity) ? host.arity : host.method(:call).arity @@ -204,6 +203,8 @@ module ActionView host = host % (Zlib.crc32(source) % 4) end + return unless host + if host =~ URI_REGEXP host else diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index 11614a45dc..67f593c22f 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -530,6 +530,17 @@ class AssetTagHelperTest < ActionView::TestCase assert_equal copy, source end + def test_image_path_with_asset_host_proc_returning_nil + @controller.config.asset_host = Proc.new do |source| + unless source.end_with?("tiff") + "cdn.example.com" + end + end + + assert_equal "/images/file.tiff", image_path("file.tiff") + assert_equal "http://cdn.example.com/images/file.png", image_path("file.png") + end + def test_caching_image_path_with_caching_and_proc_asset_host_using_request @controller.config.asset_host = Proc.new do |source, request| if request.ssl? -- cgit v1.2.3 From 6a4ff5cc0907d7dd9d1b5d606dd045116a3434ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 16 May 2013 11:09:31 -0300 Subject: Revert "Add the options method to action_controller testcase." This reverts commit 0303c2325fab253adf5e4a0b738cb469c048f008. Conflicts: actionpack/lib/action_controller/test_case.rb REASON: It will conflict with a lot of test cases. Better to call `process` directly since this is a very uncommon HTTP method. Fixes #10638. --- actionpack/lib/action_controller/test_case.rb | 6 ------ actionpack/test/controller/test_case_test.rb | 5 ----- 2 files changed, 11 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index e5f1ad63c2..0cbbbbe1fd 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -499,12 +499,6 @@ module ActionController process(action, "HEAD", *args) end - # Simulate a OPTIONS request with the given parameters and set/volley the response. - # See +get+ for more details. - def options(action, *args) - process(action, "OPTIONS", *args) - end - def xml_http_request(request_method, action, parameters = nil, session = nil, flash = nil) @request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest' @request.env['HTTP_ACCEPT'] ||= [Mime::JS, Mime::HTML, Mime::XML, 'text/xml', Mime::ALL].join(', ') diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index 38b9794b4d..7c27458f46 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -201,11 +201,6 @@ XML assert_raise(NoMethodError) { head :test_params, "document body", :id => 10 } end - def test_options - options :test_params - assert_equal 200, @response.status - end - def test_process_without_flash process :set_flash assert_equal '><', flash['test'] -- cgit v1.2.3 From c9d75e0814a3fa5797c58e3d98f76fa2990c5b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 16 May 2013 14:39:18 -0300 Subject: Revert "Integration tests support the OPTIONS http method" This reverts commit ad46884af567d6f8d6d8d777f372c39e81a560ba. Conflicts: actionpack/CHANGELOG.md actionpack/lib/action_dispatch/testing/integration.rb actionpack/test/controller/integration_test.rb Reason: It will conflict with a lot of test cases. Better to call `process` directly since this is a very uncommon HTTP method. Fixes #10638. --- actionpack/lib/action_dispatch/testing/integration.rb | 8 +------- actionpack/test/controller/integration_test.rb | 18 +----------------- 2 files changed, 2 insertions(+), 24 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index 56c31255f3..70b42ccd1b 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -62,12 +62,6 @@ module ActionDispatch process :head, path, parameters, headers_or_env end - # Performs a OPTIONS request with the given parameters. See +#get+ for - # more details. - def options(path, parameters = nil, headers_or_env = nil) - process :options, path, parameters, headers_or_env - end - # Performs an XMLHttpRequest request with the given parameters, mirroring # a request from the Prototype library. # @@ -342,7 +336,7 @@ module ActionDispatch @integration_session = Integration::Session.new(app) end - %w(get post patch put head delete options cookies assigns + %w(get post patch put head delete cookies assigns xml_http_request xhr get_via_redirect post_via_redirect).each do |method| define_method(method) do |*args| reset! unless integration_session diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index c3bdf74d93..f7ec6d71b3 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -117,12 +117,6 @@ class SessionTest < ActiveSupport::TestCase @session.head(path,params,headers) end - def test_options - path = "/index"; params = "blah"; headers = {:location => 'blah'} - @session.expects(:process).with(:options,path,params,headers) - @session.options(path,params,headers) - end - def test_xml_http_request_get path = "/index"; params = "blah"; headers = {:location => 'blah'} headers_after_xhr = headers.merge( @@ -183,16 +177,6 @@ class SessionTest < ActiveSupport::TestCase @session.xml_http_request(:head,path,params,headers) end - def test_xml_http_request_options - path = "/index"; params = "blah"; headers = {:location => 'blah'} - headers_after_xhr = headers.merge( - "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest", - "HTTP_ACCEPT" => "text/javascript, text/html, application/xml, text/xml, */*" - ) - @session.expects(:process).with(:options,path,params,headers_after_xhr) - @session.xml_http_request(:options,path,params,headers) - end - def test_xml_http_request_override_accept path = "/index"; params = "blah"; headers = {:location => 'blah', "HTTP_ACCEPT" => "application/xml"} headers_after_xhr = headers.merge( @@ -250,7 +234,7 @@ class IntegrationTestUsesCorrectClass < ActionDispatch::IntegrationTest @integration_session.stubs(:generic_url_rewriter) @integration_session.stubs(:process) - %w( get post head patch put delete options ).each do |verb| + %w( get post head patch put delete ).each do |verb| assert_nothing_raised("'#{verb}' should use integration test methods") { __send__(verb, '/') } end end -- cgit v1.2.3 From ba0695f48a28d34a9ee4d8da7ec61e15ce90a910 Mon Sep 17 00:00:00 2001 From: schneems Date: Thu, 16 May 2013 16:21:53 -0500 Subject: Fix named routing regression from 3.2.13 When named route that is nested is used in 3.2.13 Example `routes.rb`: ``` resources :nested do resources :builder, :controller => 'nested/builder' end ``` In 3.2.12 and 3.2.12 this named route would work: ``` nested_builder_path(:last_step, :nested_id => "foo") ``` Generating a url that looks like `/nested/foo/builder/last_step`. This PR fixes the regression when building urls via the optimized helper. Any explicit keys set in the options are removed from the list of implicitly mapped keys. Not sure if this is exactly how the original version worked, but this fixes this use case regression. --- actionpack/lib/action_dispatch/routing/route_set.rb | 1 + actionpack/test/dispatch/routing/route_set_test.rb | 11 +++++++++++ 2 files changed, 12 insertions(+) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 342b6ec23d..3ae9f92c0b 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -218,6 +218,7 @@ module ActionDispatch keys -= t.url_options.keys if t.respond_to?(:url_options) keys -= options.keys end + keys -= inner_options.keys result.merge!(Hash[keys.zip(args)]) end diff --git a/actionpack/test/dispatch/routing/route_set_test.rb b/actionpack/test/dispatch/routing/route_set_test.rb index d57b1a5637..0e488d2b88 100644 --- a/actionpack/test/dispatch/routing/route_set_test.rb +++ b/actionpack/test/dispatch/routing/route_set_test.rb @@ -69,6 +69,17 @@ module ActionDispatch end end + test "explicit keys win over implicit keys" do + draw do + resources :foo do + resources :bar, to: SimpleApp.new('foo#show') + end + end + + assert_equal '/foo/1/bar/2', url_helpers.foo_bar_path(1, 2) + assert_equal '/foo/1/bar/2', url_helpers.foo_bar_path(2, foo_id: 1) + end + private def clear! @set.clear! -- cgit v1.2.3