spec/acfs/runner_spec.rb in acfs-1.0.0.dev.1.b305 vs spec/acfs/runner_spec.rb in acfs-1.0.0

- old
+ new

@@ -1,9 +1,8 @@ require 'spec_helper' class NullAdapter < Acfs::Adapter::Base - # Start processing queued requests. # def start end @@ -35,38 +34,64 @@ describe ::Acfs::Runner do let(:adapter) { ::NullAdapter.new } let(:runner) { ::Acfs::Runner.new adapter } let(:collector) { NotificationCollector.new } + let(:collector2) { NotificationCollector.new } after do ::ActiveSupport::Notifications.notifier = \ ::ActiveSupport::Notifications::Fanout.new end describe '#instrumentation' do before do - ::ActiveSupport::Notifications.subscribe /^acfs\.runner/, collector + ::ActiveSupport::Notifications.subscribe(/^acfs\.runner/, collector) + ::ActiveSupport::Notifications.subscribe(/^acfs\.operation/, collector2) end describe '#process' do it 'should trigger event' do runner.process ::Acfs::Operation.new MyUser, :read, params: {id: 0} expect(collector.events).to have(1).items + expect(collector2.events).to have(1).items end end describe '#run' do it 'should trigger event' do runner.run ::Acfs::Operation.new MyUser, :read, params: {id: 0} expect(collector.events).to have(1).items + expect(collector2.events).to have(0).items end end describe '#enqueue' do it 'should trigger event' do - runner.run ::Acfs::Operation.new MyUser, :read, params: {id: 0} + runner.enqueue ::Acfs::Operation.new MyUser, :read, params: {id: 0} expect(collector.events).to have(1).items + expect(collector2.events).to have(0).items end + end + end + + describe '#run' do + before do + expect_any_instance_of(UserService).to receive(:prepare).and_return nil + end + it 'it should not do requests when a middleware aborted' do + expect(adapter).to_not receive :run + runner.run ::Acfs::Operation.new MyUser, :read, params: {id: 0} + end + end + + describe '#enqueue' do + before do + expect_any_instance_of(UserService).to receive(:prepare).and_return nil + end + it 'it should not do requests when a middleware aborted' do + expect(adapter).to_not receive :queue + runner.enqueue ::Acfs::Operation.new MyUser, :read, params: {id: 0} + runner.start end end end