提交 67a2b5ec 编写于 作者: N Neeraj Singh 提交者: José Valim

If certain sections of skip_callback method are commented out then

no test was failing. Tests have been added to ensure that commenting
out the code within if loop would cause test failure.
Signed-off-by: NJosé Valim <jose.valim@gmail.com>
上级 d8db5714
......@@ -524,4 +524,31 @@ def test_save
assert_equal "ACTION", obj.stuff
end
end
class WriterSkipper < Person
attr_accessor :age
skip_callback :save, :before, :before_save_method, :if => lambda {self.age > 21}
end
class WriterCallbacksTest < Test::Unit::TestCase
def test_skip_writer
writer = WriterSkipper.new
writer.age = 18
assert_equal [], writer.history
writer.save
assert_equal [
[:before_save, :symbol],
[:before_save, :string],
[:before_save, :proc],
[:before_save, :object],
[:before_save, :block],
[:after_save, :block],
[:after_save, :object],
[:after_save, :proc],
[:after_save, :string],
[:after_save, :symbol]
], writer.history
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册