test/test_web.rb in zhong-0.1.9 vs test/test_web.rb in zhong-0.2.0

- old
+ new

@@ -30,12 +30,17 @@ assert_contains "test_web_job", last_response.body assert_contains "every 10 minutes", last_response.body end def test_disable_job + test_before_disable = 0 + test_after_disable = 0 + Zhong.schedule do every(30.seconds, "test_disable_web_job") { nil } + on(:before_disable) { test_before_disable += 1 } + on(:after_disable) { test_after_disable += 1 } end job = Zhong.scheduler.find_by_name("test_disable_web_job") job.enable @@ -46,15 +51,22 @@ assert last_response.ok? assert_contains "test_disable_web_job", last_response.body assert_contains "every 30 seconds", last_response.body assert_contains 'name="enable"', last_response.body assert_equal true, job.disabled? + assert_equal 1, test_before_disable + assert_equal 1, test_after_disable end def test_enable_job + test_before_enable = 0 + test_after_enable = 0 + Zhong.schedule do every(12.hours, "test_enable_web_job") { nil } + on(:before_enable) { test_before_enable += 1 } + on(:after_enable) { test_after_enable += 1 } end job = Zhong.scheduler.find_by_name("test_enable_web_job") job.disable @@ -65,9 +77,11 @@ assert last_response.ok? assert_contains "test_enable_web_job", last_response.body assert_contains "every 12 hours", last_response.body assert_contains 'name="disable"', last_response.body assert_equal false, job.disabled? + assert_equal 1, test_before_enable + assert_equal 1, test_after_enable end def test_heartbeat hostname = `hostname`.strip pid = Process.pid