mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Clear inflections after test.
This commit is contained in:
parent
0f80a52629
commit
781f8a8a33
1 changed files with 19 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue