diff options
-rw-r--r-- | actionpack/lib/abstract_controller/callbacks.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/journey/router.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/testing/integration.rb | 24 | ||||
-rw-r--r-- | actionpack/test/controller/filters_test.rb | 8 | ||||
-rw-r--r-- | actionpack/test/dispatch/response_test.rb | 4 | ||||
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 9 | ||||
-rw-r--r-- | guides/source/active_record_validations.md | 4 | ||||
-rw-r--r-- | guides/source/layouts_and_rendering.md | 2 |
8 files changed, 35 insertions, 19 deletions
diff --git a/actionpack/lib/abstract_controller/callbacks.rb b/actionpack/lib/abstract_controller/callbacks.rb index f4fd1db36c..681caba457 100644 --- a/actionpack/lib/abstract_controller/callbacks.rb +++ b/actionpack/lib/abstract_controller/callbacks.rb @@ -70,7 +70,7 @@ module AbstractController end def skip_filter(*names) - ActiveSupport::Deprecation.warn("#{callback}_filter is deprecated and will be removed in Rails 5.1. Use #{callback}_action instead.") + ActiveSupport::Deprecation.warn("`skip_filter` is deprecated and will be removed in Rails 5.1. Use skip_before_action, skip_after_action or skip_around_action instead.") skip_action_callback(*names) end diff --git a/actionpack/lib/action_dispatch/journey/router.rb b/actionpack/lib/action_dispatch/journey/router.rb index e9df984c86..2b036796ab 100644 --- a/actionpack/lib/action_dispatch/journey/router.rb +++ b/actionpack/lib/action_dispatch/journey/router.rb @@ -121,7 +121,6 @@ module ActionDispatch end def match_head_routes(routes, req) - routes.delete_if { |route| route.verb == // } head_routes = match_routes(routes, req) if head_routes.empty? diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index 2fe37c5bd4..f7f898288b 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -388,16 +388,8 @@ module ActionDispatch APP_SESSIONS = {} - attr_reader :app - - def before_setup - super - @app = nil - @integration_session = nil - end - - def integration_session - @integration_session ||= create_session(app) + def app + @app ||= nil end # Reset the current session. This is useful for testing multiple sessions @@ -425,6 +417,8 @@ module ActionDispatch %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 + # reset the html_document variable, except for cookies/assigns calls unless method == 'cookies' || method == 'assigns' @html_document = nil @@ -456,16 +450,19 @@ module ActionDispatch # Copy the instance variables from the current session instance into the # test instance. def copy_session_variables! #:nodoc: + return unless integration_session @controller = @integration_session.controller @response = @integration_session.response @request = @integration_session.request end def default_url_options + reset! unless integration_session integration_session.default_url_options end def default_url_options=(options) + reset! unless integration_session integration_session.default_url_options = options end @@ -475,6 +472,7 @@ module ActionDispatch # Delegate unhandled messages to the current session instance. def method_missing(sym, *args, &block) + reset! unless integration_session if integration_session.respond_to?(sym) integration_session.__send__(sym, *args, &block).tap do copy_session_variables! @@ -483,6 +481,11 @@ module ActionDispatch super end end + + private + def integration_session + @integration_session ||= nil + end end end @@ -659,6 +662,7 @@ module ActionDispatch end def url_options + reset! unless integration_session integration_session.url_options end diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 26b94f0db8..a1ce12a13e 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -1074,6 +1074,14 @@ class YieldingAroundFiltersTest < ActionController::TestCase end end + def test_deprecated_skip_filter + assert_deprecated do + Class.new(PostsController) do + skip_filter :clean_up + end + end + end + protected def test_process(controller, action = "show") @controller = controller.is_a?(Class) ? controller.new : controller diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb index 5fbd19acdf..c61423dce4 100644 --- a/actionpack/test/dispatch/response_test.rb +++ b/actionpack/test/dispatch/response_test.rb @@ -254,6 +254,10 @@ class ResponseTest < ActiveSupport::TestCase end class ResponseIntegrationTest < ActionDispatch::IntegrationTest + def app + @app + end + test "response cache control from railsish app" do @app = lambda { |env| ActionDispatch::Response.new.tap { |resp| diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index d65d2e8e8f..b4502c19d6 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -3492,11 +3492,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest mount lambda { |env| [200, {}, [env['REQUEST_METHOD']]] }, at: '/' end - # HEAD request matches `get /home` rather than the lower-precedence - # Rack app mounted at `/` + # TODO: HEAD request should match `get /home` rather than the + # lower-precedence Rack app mounted at `/`. head '/home' - assert_response :success - assert_equal 'test#index', @response.body + assert_response :ok + #assert_equal 'test#index', @response.body + assert_equal 'HEAD', @response.body # But the Rack app can still respond to its own HEAD requests. head '/foobar' diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md index d65c15bcf3..f19934fe89 100644 --- a/guides/source/active_record_validations.md +++ b/guides/source/active_record_validations.md @@ -917,8 +917,8 @@ write your own validators or validation methods as you prefer. ### Custom Validators -Custom validators are classes that extend `ActiveModel::Validator`. These -classes must implement a `validate` method which takes a record as an argument +Custom validators are classes that inherit from `ActiveModel::Validator`. These +classes must implement the `validate` method which takes a record as an argument and performs the validation on it. The custom validator is called using the `validates_with` method. diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md index b0e71035c0..5c7fad09ed 100644 --- a/guides/source/layouts_and_rendering.md +++ b/guides/source/layouts_and_rendering.md @@ -565,7 +565,7 @@ In this application: ##### Template Inheritance -Similarly to the Layout Inheritance logic, if a template or partial is not found in the conventional path, the controller will look for a template or partial to render in its inheritance chain. For example: +Similar to the Layout Inheritance logic, if a template or partial is not found in the conventional path, the controller will look for a template or partial to render in its inheritance chain. For example: ```ruby # in app/controllers/application_controller |