Skip to content

Commit

Permalink
Ensure params wrapper settings are not inherited and calculated each …
Browse files Browse the repository at this point in the history
…time.
  • Loading branch information
josevalim committed May 6, 2011
1 parent 41a6d96 commit 785ee65
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/metal/params_wrapper.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def wrap_parameters(name_or_model_or_options, options = {})
# module is inherited. # module is inherited.
def inherited(klass) def inherited(klass)
if klass._wrapper_options[:format].present? if klass._wrapper_options[:format].present?
klass._set_wrapper_defaults(klass._wrapper_options) klass._set_wrapper_defaults(klass._wrapper_options.slice(:format))
end end
super super
end end
Expand Down
30 changes: 27 additions & 3 deletions railties/test/application/configuration_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def self.delivered_email(email); email; end


class ::MyOtherMailObserver < ::MyMailObserver; end class ::MyOtherMailObserver < ::MyMailObserver; end



module ApplicationTests module ApplicationTests
class ConfigurationTest < Test::Unit::TestCase class ConfigurationTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation include ActiveSupport::Testing::Isolation
Expand Down Expand Up @@ -437,10 +436,35 @@ def index
app_file 'config/initializers/wrap_parameters.rb', <<-RUBY app_file 'config/initializers/wrap_parameters.rb', <<-RUBY
ActionController::Base.wrap_parameters :format => [:json] ActionController::Base.wrap_parameters :format => [:json]
RUBY 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 "#{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 end


test "config.action_dispatch.ignore_accept_header" do test "config.action_dispatch.ignore_accept_header" do
Expand Down

0 comments on commit 785ee65

Please sign in to comment.