test/models/hook_test.rb in shipit-engine-0.27.0 vs test/models/hook_test.rb in shipit-engine-0.27.1

- old
+ new

@@ -40,7 +40,36 @@ refute @hook.scoped? @hook.stack_id = 42 assert @hook.scoped? end + + test ".emit schedules an EmitEventJob" do + assert_enqueued_jobs(1, only: EmitEventJob) do + Hook.emit(:deploy, @stack, 'foo' => 42) + end + end + + test ".emit calls #deliver on internal hooks" do + begin + original_receivers = Shipit.internal_hook_receivers + FakeReceiver = Module.new + FakeReceiver.expects(:deliver).with(:deploy, @stack, 'foo' => 42) + + Shipit.internal_hook_receivers << FakeReceiver + Hook.emit(:deploy, @stack, 'foo' => 42) + ensure + Shipit.internal_hook_receivers = original_receivers + end + end + + test ".emit calls no internal hooks if there are no internal_hook_receivers" do + begin + original_receivers = Shipit.internal_hook_receivers + Shipit.internal_hook_receivers = nil + Hook.emit(:deploy, @stack, 'foo' => 42) + ensure + Shipit.internal_hook_receivers = original_receivers + end + end end end