diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-05-29 01:13:17 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-05-29 01:13:17 +0200 |
commit | b8be14acdccf563bb2364c8ec5cb9b185a43cfd3 (patch) | |
tree | 4a9638868350ed7a6a7410b6b76c71a4dc35f826 | |
parent | c0d1823d546541295ed914a03c7c889951b02828 (diff) | |
parent | 781f8a8a3308938df6b1a6fd6073dcec7f988ec8 (diff) | |
download | rails-b8be14acdccf563bb2364c8ec5cb9b185a43cfd3.tar.gz rails-b8be14acdccf563bb2364c8ec5cb9b185a43cfd3.tar.bz2 rails-b8be14acdccf563bb2364c8ec5cb9b185a43cfd3.zip |
Merge pull request #15384 from zuhao/refactor_actionpack_params_wrapper_test
Clear inflections after test.
-rw-r--r-- | actionpack/test/controller/params_wrapper_test.rb | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/actionpack/test/controller/params_wrapper_test.rb b/actionpack/test/controller/params_wrapper_test.rb index 11ccb6cf3b..645ecae220 100644 --- a/actionpack/test/controller/params_wrapper_test.rb +++ b/actionpack/test/controller/params_wrapper_test.rb @@ -337,14 +337,26 @@ class IrregularInflectionParamsWrapperTest < ActionController::TestCase tests ParamswrappernewsController def test_uses_model_attribute_names_with_irregular_inflection - ActiveSupport::Inflector.inflections do |inflect| - inflect.irregular 'paramswrappernews_item', 'paramswrappernews' - end + with_dup do + 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' }}) + 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 + + private + + def with_dup + original = ActiveSupport::Inflector::Inflections.instance_variable_get(:@__instance__)[:en] + ActiveSupport::Inflector::Inflections.instance_variable_set(:@__instance__, en: original.dup) + yield + ensure + ActiveSupport::Inflector::Inflections.instance_variable_set(:@__instance__, en: original) + end end |