tests: add more post/pool version creation tests.

Adds the `test_after_commit` gem too because after_commit callbacks
don't fire inside tests in rails <5.0.
This commit is contained in:
evazion
2017-04-01 03:32:02 -05:00
committed by r888888888
parent 8fff3315f2
commit 3c89ee3199
4 changed files with 57 additions and 2 deletions

View File

@@ -238,6 +238,20 @@ class PoolTest < ActiveSupport::TestCase
assert_equal(2, @pool.versions.size)
end
should "not create a version if updating the pool fails" do
@pool.stubs(:synchronize!).raises(NotImplementedError)
assert_raise(NotImplementedError) { @pool.update(name: "blah") }
assert_equal(1, @pool.versions.size)
end
should "should create a version if the name changes" do
assert_difference("@pool.versions.size", 1) do
@pool.update(name: "blah")
assert_equal("blah", @pool.versions.last.name)
end
end
should "know what its post ids were previously" do
@pool.post_ids = "#{@p1.id}"
assert_equal("", @pool.post_ids_was)