diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2011-03-16 19:31:57 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-03-16 21:01:49 -0300 |
commit | 52320775175275379b1b215274dc26bed7f43634 (patch) | |
tree | 151c39759ea81b7d04314e4d7cb60264ed66325b | |
parent | cb44e99de46e924bdceab9294fbaea9732e9dba6 (diff) | |
download | rails-52320775175275379b1b215274dc26bed7f43634.tar.gz rails-52320775175275379b1b215274dc26bed7f43634.tar.bz2 rails-52320775175275379b1b215274dc26bed7f43634.zip |
Add test for define_attr_method using as name an invalid identifier
-rw-r--r-- | activemodel/test/cases/attribute_methods_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activemodel/test/cases/attribute_methods_test.rb b/activemodel/test/cases/attribute_methods_test.rb index 4cfec66015..3df76295cf 100644 --- a/activemodel/test/cases/attribute_methods_test.rb +++ b/activemodel/test/cases/attribute_methods_test.rb @@ -41,6 +41,12 @@ class ModelWithWeirdNamesAttributes attribute_method_suffix '' + class << self + define_method(:'c?d') do + 'c?d' + end + end + def attributes { :'a?b' => 'value of a?b' } end @@ -86,6 +92,13 @@ class AttributeMethodsTest < ActiveModel::TestCase assert_equal "value of foo bar", ModelWithAttributesWithSpaces.new.send(:'foo bar') end + test '#define_attr_method generates attribute method with invalid identifier characters' do + ModelWithWeirdNamesAttributes.define_attr_method(:'c?d', 'c?d') + + assert_respond_to ModelWithWeirdNamesAttributes, :'c?d' + assert_equal "c?d", ModelWithWeirdNamesAttributes.send('c?d') + end + test '#alias_attribute works with attributes with spaces in their names' do ModelWithAttributesWithSpaces.define_attribute_methods([:'foo bar']) ModelWithAttributesWithSpaces.alias_attribute(:'foo_bar', :'foo bar') |