diff options
author | Jay Pignata <john.pignata@gmail.com> | 2009-09-04 17:28:36 -0400 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2009-09-28 14:48:13 +1300 |
commit | d48ebeade2d907573e3fb086495b57b10115066c (patch) | |
tree | c5c98e01f7711c0899201b5a47ebc8e08c2d16f6 /activesupport/test | |
parent | e01f99786a586e41a36d3c1ddc66f080d04b4036 (diff) | |
download | rails-d48ebeade2d907573e3fb086495b57b10115066c.tar.gz rails-d48ebeade2d907573e3fb086495b57b10115066c.tar.bz2 rails-d48ebeade2d907573e3fb086495b57b10115066c.zip |
Escaping symbol passed into Memoizable's flush_cache for query methods to allow them to be cleared
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#3138 state:committed]
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/memoizable_test.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/activesupport/test/memoizable_test.rb b/activesupport/test/memoizable_test.rb index 3bad683093..195e3eaa42 100644 --- a/activesupport/test/memoizable_test.rb +++ b/activesupport/test/memoizable_test.rb @@ -4,12 +4,13 @@ class MemoizableTest < ActiveSupport::TestCase class Person extend ActiveSupport::Memoizable - attr_reader :name_calls, :age_calls, :is_developer_calls + attr_reader :name_calls, :age_calls, :is_developer_calls, :name_query_calls def initialize @name_calls = 0 @age_calls = 0 @is_developer_calls = 0 + @name_query_calls = 0 end def name @@ -18,6 +19,7 @@ class MemoizableTest < ActiveSupport::TestCase end def name? + @name_query_calls += 1 true end memoize :name? @@ -116,6 +118,13 @@ class MemoizableTest < ActiveSupport::TestCase end end + def test_memoization_flush_with_punctuation + assert_equal true, @person.name? + @person.flush_cache(:name?) + 3.times { assert_equal true, @person.name? } + assert_equal 2, @person.name_query_calls + end + def test_memoization_with_nil_value assert_equal nil, @person.age assert_equal 1, @person.age_calls |