Skip to content

Commit

Permalink
If certain sections of skip_callback method are commented out then
Browse files Browse the repository at this point in the history
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: José Valim <jose.valim@gmail.com>
  • Loading branch information
Neeraj Singh authored and josevalim committed Aug 31, 2010
1 parent d8db571 commit 67a2b5e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions activesupport/test/callbacks_test.rb
Expand Up @@ -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

0 comments on commit 67a2b5e

Please sign in to comment.