Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Test for after_create callback order in ActiveSupport [#5703 state:re…
…solved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
Neeraj Singh authored and josevalim committed Sep 27, 2010
1 parent 72c1e19 commit bfc9868
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions activesupport/test/callbacks_test.rb
Expand Up @@ -149,6 +149,27 @@ def test_optimized_first_compile
end
end

class AfterSaveConditionalPerson < Record
after_save Proc.new { |r| r.history << [:after_save, :string1] }
after_save Proc.new { |r| r.history << [:after_save, :string2] }
def save
run_callbacks :save
end
end

class AfterSaveConditionalPersonCallbackTest < Test::Unit::TestCase
def test_after_save_runs_in_the_reverse_order
person = AfterSaveConditionalPerson.new
person.save
assert_equal [
[:after_save, :string2],
[:after_save, :string1]
], person.history
end
end



class ConditionalPerson < Record
# proc
before_save Proc.new { |r| r.history << [:before_save, :proc] }, :if => Proc.new { |r| true }
Expand Down Expand Up @@ -352,6 +373,8 @@ def test_save_conditional_person
end
end



class ResetCallbackTest < Test::Unit::TestCase
def test_save_conditional_person
person = CleanPerson.new
Expand Down

0 comments on commit bfc9868

Please sign in to comment.