diff options
author | José Valim <jose.valim@gmail.com> | 2011-12-05 08:46:10 -0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-12-05 08:46:10 -0800 |
commit | 168c088735d47ecb4347541afcbf4a873f50319a (patch) | |
tree | fdea4439e2d7270f9b5ee60ef11999a8b71e5e4b /actionpack/test/controller/params_wrapper_test.rb | |
parent | d4964b338667fb14d7755cd90af88bb267238958 (diff) | |
parent | 1f0e21ce3037b03a125229810d584db77c0c6ed4 (diff) | |
download | rails-168c088735d47ecb4347541afcbf4a873f50319a.tar.gz rails-168c088735d47ecb4347541afcbf4a873f50319a.tar.bz2 rails-168c088735d47ecb4347541afcbf4a873f50319a.zip |
Merge pull request #3863 from lest/params-wrapper-inflections
use classify in ParamsWrapper to derive model name from controller name
Diffstat (limited to 'actionpack/test/controller/params_wrapper_test.rb')
-rw-r--r-- | actionpack/test/controller/params_wrapper_test.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/actionpack/test/controller/params_wrapper_test.rb b/actionpack/test/controller/params_wrapper_test.rb index 7bef1e8d5d..0102f66dfe 100644 --- a/actionpack/test/controller/params_wrapper_test.rb +++ b/actionpack/test/controller/params_wrapper_test.rb @@ -285,3 +285,38 @@ class AnonymousControllerParamsWrapperTest < ActionController::TestCase end end end + +class IrregularInflectionParamsWrapperTest < ActionController::TestCase + include ParamsWrapperTestHelp + + class ParamswrappernewsItem + def self.attribute_names + ['test_attr'] + end + end + + class ParamswrappernewsController < ActionController::Base + class << self + attr_accessor :last_parameters + end + + def parse + self.class.last_parameters = request.params.except(:controller, :action) + head :ok + end + end + + tests ParamswrappernewsController + + def test_uses_model_attribute_names_with_irregular_inflection + ActiveSupport::Inflector.inflections do |inflect| + inflect.irregular 'paramswrappernews_item', 'paramswrappernews' + end + + with_default_wrapper_options do + @request.env['CONTENT_TYPE'] = 'application/json' + post :parse, { 'username' => 'sikachu', 'test_attr' => 'test_value' } + assert_parameters({ 'username' => 'sikachu', 'test_attr' => 'test_value', 'paramswrappernews_item' => { 'test_attr' => 'test_value' }}) + end + end +end |