mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Ensure params wrapper settings are not inherited and calculated each time.
This commit is contained in:
parent
41a6d96c1b
commit
785ee65ddf
2 changed files with 29 additions and 5 deletions
|
@ -125,7 +125,7 @@ module ActionController
|
|||
# module is inherited.
|
||||
def inherited(klass)
|
||||
if klass._wrapper_options[:format].present?
|
||||
klass._set_wrapper_defaults(klass._wrapper_options)
|
||||
klass._set_wrapper_defaults(klass._wrapper_options.slice(:format))
|
||||
end
|
||||
super
|
||||
end
|
||||
|
|
|
@ -12,7 +12,6 @@ end
|
|||
|
||||
class ::MyOtherMailObserver < ::MyMailObserver; end
|
||||
|
||||
|
||||
module ApplicationTests
|
||||
class ConfigurationTest < Test::Unit::TestCase
|
||||
include ActiveSupport::Testing::Isolation
|
||||
|
@ -437,10 +436,35 @@ module ApplicationTests
|
|||
app_file 'config/initializers/wrap_parameters.rb', <<-RUBY
|
||||
ActionController::Base.wrap_parameters :format => [:json]
|
||||
RUBY
|
||||
require "#{app_path}/config/environment"
|
||||
require 'action_controller/base'
|
||||
|
||||
assert_equal [:json], ActionController::Base._wrapper_options[:format]
|
||||
app_file 'app/models/post.rb', <<-RUBY
|
||||
class Post
|
||||
def self.column_names
|
||||
%w(title)
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
|
||||
app_file 'app/controllers/posts_controller.rb', <<-RUBY
|
||||
class PostsController < ApplicationController
|
||||
def index
|
||||
render :text => params[:post].inspect
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
|
||||
add_to_config <<-RUBY
|
||||
routes.append do
|
||||
resources :posts
|
||||
end
|
||||
RUBY
|
||||
|
||||
require "#{app_path}/config/environment"
|
||||
require "rack/test"
|
||||
extend Rack::Test::Methods
|
||||
|
||||
post "/posts.json", '{ "title": "foo", "name": "bar" }', "CONTENT_TYPE" => "application/json"
|
||||
assert_equal '{"title"=>"foo"}', last_response.body
|
||||
end
|
||||
|
||||
test "config.action_dispatch.ignore_accept_header" do
|
||||
|
|
Loading…
Reference in a new issue