diff options
author | Lachlan Sylvester <lachlan.sylvester@publicisfrontfoot.com.au> | 2015-08-07 20:05:02 +1000 |
---|---|---|
committer | Lachlan Sylvester <lachlan.sylvester@publicisfrontfoot.com.au> | 2015-08-07 20:05:02 +1000 |
commit | a51dad1c525c674ba9e08697332f86790e3570ca (patch) | |
tree | beb481e05e5772d2a188938ca535d0dcd2beb534 /activesupport/test/core_ext/module/attribute_accessor_test.rb | |
parent | 4b91db5b125dd7bd735e7f42eb8e2c14c0e6757e (diff) | |
download | rails-a51dad1c525c674ba9e08697332f86790e3570ca.tar.gz rails-a51dad1c525c674ba9e08697332f86790e3570ca.tar.bz2 rails-a51dad1c525c674ba9e08697332f86790e3570ca.zip |
Only invoke the default block for mattr_accessor once so that it does not cause issues if it is not idempotent
Diffstat (limited to 'activesupport/test/core_ext/module/attribute_accessor_test.rb')
-rw-r--r-- | activesupport/test/core_ext/module/attribute_accessor_test.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module/attribute_accessor_test.rb b/activesupport/test/core_ext/module/attribute_accessor_test.rb index 48f3cc579f..128c5e3d1a 100644 --- a/activesupport/test/core_ext/module/attribute_accessor_test.rb +++ b/activesupport/test/core_ext/module/attribute_accessor_test.rb @@ -76,4 +76,10 @@ class ModuleAttributeAccessorTest < ActiveSupport::TestCase assert_equal 'default_reader_value', @module.defr assert_equal 'default_writer_value', @module.class_variable_get('@@defw') end + + def test_should_not_invoke_default_value_block_multiple_times + count = 0 + @module.cattr_accessor(:defcount){ count += 1 } + assert_equal 1, count + end end |