diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-14 11:34:35 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-14 11:35:15 -0500 |
commit | 05234b358f2d8fabb41b16a4a7a8d676bc31dcd3 (patch) | |
tree | bffd2a581ac56b43e7b95056d87fc9abec30fadd /activemodel/test | |
parent | 017632fe2b45fca68685bed2dabfa97bb6722351 (diff) | |
download | rails-05234b358f2d8fabb41b16a4a7a8d676bc31dcd3.tar.gz rails-05234b358f2d8fabb41b16a4a7a8d676bc31dcd3.tar.bz2 rails-05234b358f2d8fabb41b16a4a7a8d676bc31dcd3.zip |
allow define_attribute_methods to pass multiple values
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/attribute_methods_test.rb | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/activemodel/test/cases/attribute_methods_test.rb b/activemodel/test/cases/attribute_methods_test.rb index 34298d31c2..a9db29ee21 100644 --- a/activemodel/test/cases/attribute_methods_test.rb +++ b/activemodel/test/cases/attribute_methods_test.rb @@ -10,7 +10,7 @@ class ModelWithAttributes end def attributes - { :foo => 'value of foo' } + { :foo => 'value of foo', :baz => 'value of baz' } end private @@ -127,29 +127,36 @@ class AttributeMethodsTest < ActiveModel::TestCase assert_equal "value of a?b", ModelWithWeirdNamesAttributes.new.send('a?b') end + test '#define_attribute_methods works passing multiple arguments' do + ModelWithAttributes.define_attribute_methods(:foo, :baz) + + assert_equal "value of foo", ModelWithAttributes.new.foo + assert_equal "value of baz", ModelWithAttributes.new.baz + end + test '#define_attribute_methods generates attribute methods' do - ModelWithAttributes.define_attribute_methods([:foo]) + ModelWithAttributes.define_attribute_methods(:foo) assert_respond_to ModelWithAttributes.new, :foo assert_equal "value of foo", ModelWithAttributes.new.foo end test '#define_attribute_methods generates attribute methods with spaces in their names' do - ModelWithAttributesWithSpaces.define_attribute_methods([:'foo bar']) + ModelWithAttributesWithSpaces.define_attribute_methods(:'foo bar') assert_respond_to ModelWithAttributesWithSpaces.new, :'foo bar' assert_equal "value of foo bar", ModelWithAttributesWithSpaces.new.send(:'foo bar') end test '#alias_attribute works with attributes with spaces in their names' do - ModelWithAttributesWithSpaces.define_attribute_methods([:'foo bar']) + ModelWithAttributesWithSpaces.define_attribute_methods(:'foo bar') ModelWithAttributesWithSpaces.alias_attribute(:'foo_bar', :'foo bar') assert_equal "value of foo bar", ModelWithAttributesWithSpaces.new.foo_bar end test '#undefine_attribute_methods removes attribute methods' do - ModelWithAttributes.define_attribute_methods([:foo]) + ModelWithAttributes.define_attribute_methods(:foo) ModelWithAttributes.undefine_attribute_methods assert !ModelWithAttributes.new.respond_to?(:foo) @@ -170,7 +177,7 @@ class AttributeMethodsTest < ActiveModel::TestCase assert_deprecated { klass.attribute_method_suffix '' } assert_deprecated { klass.attribute_method_prefix '' } - klass.define_attribute_methods([:foo]) + klass.define_attribute_methods(:foo) assert_equal 'value of foo', klass.new.foo end |