From 34509777fd375e5bc529f21ca66cf63263c2cf64 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Mon, 27 Apr 2009 18:16:55 -0700 Subject: Makes new callbacks support keys with special characters --- activesupport/test/new_callbacks_test.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'activesupport/test/new_callbacks_test.rb') diff --git a/activesupport/test/new_callbacks_test.rb b/activesupport/test/new_callbacks_test.rb index abe7790ebf..8c887e1bf1 100644 --- a/activesupport/test/new_callbacks_test.rb +++ b/activesupport/test/new_callbacks_test.rb @@ -255,6 +255,26 @@ module NewCallbacksTest end end + class HyphenatedCallbacks + include ActiveSupport::NewCallbacks + define_callbacks :save + attr_reader :stuff + + save_callback :before, :omg, :per_key => {:if => :yes} + + def yes() true end + + def omg + @stuff = "OMG" + end + + def save + _run_save_callbacks("hyphen-ated") do + @stuff + end + end + end + class AroundCallbacksTest < Test::Unit::TestCase def test_save_around around = AroundPerson.new @@ -381,4 +401,12 @@ module NewCallbacksTest assert_equal ["first", "second", "third", "second", "first"], terminator.history end end + + class HyphenatedKeyTest < Test::Unit::TestCase + def test_save + obj = HyphenatedCallbacks.new + obj.save + assert_equal obj.stuff, "OMG" + end + end end -- cgit v1.2.3