diff --git a/activesupport/lib/active_support/xml_mini.rb b/activesupport/lib/active_support/xml_mini.rb index a1728ab955d71a73b3b517eabc56396808532e8c..cddfcddb5733cb0e3b1ad360ef76800bc7253be6 100644 --- a/activesupport/lib/active_support/xml_mini.rb +++ b/activesupport/lib/active_support/xml_mini.rb @@ -126,14 +126,10 @@ def to_tag(key, value, options) end def rename_key(key, options = {}) - camelize = options.has_key?(:camelize) && options[:camelize] + camelize = options[:camelize] dasherize = !options.has_key?(:dasherize) || options[:dasherize] if camelize - if options[:camelize] == :lower - key = key.camelize(:lower) - else - key = key.camelize - end + key = true == camelize ? key.camelize : key.camelize(camelize) end key = _dasherize(key) if dasherize key diff --git a/activesupport/test/test_xml_mini.rb b/activesupport/test/test_xml_mini.rb index b14a3e154663963d62d8aebad31dc25b5a09765f..309fa234bfd48cd4e9528d37a207b489d55acfa8 100644 --- a/activesupport/test/test_xml_mini.rb +++ b/activesupport/test/test_xml_mini.rb @@ -14,6 +14,14 @@ def test_rename_key_does_nothing_with_dasherize_false assert_equal "my_key", ActiveSupport::XmlMini.rename_key("my_key", :dasherize => false) end + def test_rename_key_camelizes_with_camelize_false + assert_equal "my_key", ActiveSupport::XmlMini.rename_key("my_key", :camelize => false) + end + + def test_rename_key_camelizes_with_camelize_nil + assert_equal "my_key", ActiveSupport::XmlMini.rename_key("my_key", :camelize => nil) + end + def test_rename_key_camelizes_with_camelize_true assert_equal "MyKey", ActiveSupport::XmlMini.rename_key("my_key", :camelize => true) end @@ -22,6 +30,10 @@ def test_rename_key_lower_camelizes_with_camelize_lower assert_equal "myKey", ActiveSupport::XmlMini.rename_key("my_key", :camelize => :lower) end + def test_rename_key_lower_camelizes_with_camelize_upper + assert_equal "MyKey", ActiveSupport::XmlMini.rename_key("my_key", :camelize => :upper) + end + def test_rename_key_does_not_dasherize_leading_underscores assert_equal "_id", ActiveSupport::XmlMini.rename_key("_id") end