class IrregularInflectionParamsWrapperTest

Public Instance Methods

test_uses_model_attribute_names_with_irregular_inflection() click to toggle source
# File actionpack/test/controller/params_wrapper_test.rb, line 385
def test_uses_model_attribute_names_with_irregular_inflection
  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, params: { "username" => "sikachu", "test_attr" => "test_value" }
      assert_parameters("username" => "sikachu", "test_attr" => "test_value", "paramswrappernews_item" => { "test_attr" => "test_value" })
    end
  end
end

Private Instance Methods

with_dup() { || ... } click to toggle source
# File actionpack/test/controller/params_wrapper_test.rb, line 401
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