Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ensure params wrapper settings are not inherited and calculated each …

…time.
  • Loading branch information...
commit 785ee65ddfc3cd361ea2a0dbde3bfb908ed62192 1 parent 41a6d96
@josevalim josevalim authored
View
2  actionpack/lib/action_controller/metal/params_wrapper.rb
@@ -125,7 +125,7 @@ def wrap_parameters(name_or_model_or_options, options = {})
# 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
View
30 railties/test/application/configuration_test.rb
@@ -12,7 +12,6 @@ def self.delivered_email(email); email; end
class ::MyOtherMailObserver < ::MyMailObserver; end
-
module ApplicationTests
class ConfigurationTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
@@ -437,10 +436,35 @@ def index
app_file 'config/initializers/wrap_parameters.rb', <<-RUBY
ActionController::Base.wrap_parameters :format => [:json]
RUBY
+
+ 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 'action_controller/base'
+ require "rack/test"
+ extend Rack::Test::Methods
- assert_equal [:json], ActionController::Base._wrapper_options[:format]
+ 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
Please sign in to comment.
Something went wrong with that request. Please try again.