spec/models/concerns/subscribable_spec.rb in reactor-0.18.0 vs spec/models/concerns/subscribable_spec.rb in reactor-0.19.0
- old
+ new
@@ -1,8 +1,8 @@
require 'spec_helper'
-class Auction < ActiveRecord::Base
+class Auction < ApplicationRecord
on_event :bid_made do |event|
event.target.update_column :status, 'first_bid_made'
end
on_event :puppy_delivered, :ring_bell
@@ -66,11 +66,11 @@
end
end
end
Reactor.in_test_mode do
- class TestModeAuction < ActiveRecord::Base
+ class TestModeAuction < ApplicationRecord
on_event :test_puppy_delivered, -> (event) { "success" }
end
end
describe Reactor::Subscribable do
@@ -161,9 +161,24 @@
end
it 'keeps default options when none supplied' do
expect(Reactor::StaticSubscribers::Auction::WildcardHandler.get_sidekiq_options).
to eql({ 'queue' => 'default', 'retry' => true })
+ end
+ end
+
+ describe 'overriding queue options with ENV variable to isolate cascade between processes' do
+ before { ENV['REACTOR_QUEUE'] = 'bulk' }
+ after { ENV.delete('REACTOR_QUEUE') }
+
+ specify do
+ expect_any_instance_of(Reactor::StaticSubscribers::Auction::WildcardHandler).
+ to receive(:perform)
+
+ expect(Reactor::StaticSubscribers::Auction::WildcardHandler).to receive(:set).
+ with(hash_including(queue: 'bulk')).and_call_original
+
+ Reactor::Event.publish(:puppy_delivered)
end
end
describe '#perform' do
around(:each) do |example|