From 73bcabdc461df2958f3d71531b9b648deeeeaf3c Mon Sep 17 00:00:00 2001 From: Santiago Diaz Date: Wed, 4 Oct 2023 12:28:58 -0300 Subject: [PATCH] [WIP] - Spec for outbox class not found error --- lib/active_outbox/outboxable.rb | 2 +- spec/lib/active_outbox/outboxable_spec.rb | 12 ++++++++++++ spec/support/00_outbox_config.rb | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/active_outbox/outboxable.rb b/lib/active_outbox/outboxable.rb index 16e79d9..e6b258b 100644 --- a/lib/active_outbox/outboxable.rb +++ b/lib/active_outbox/outboxable.rb @@ -70,11 +70,11 @@ def outbox_model_name! def namespace_outbox_mapping namespace = self.class.name.split('/').first - ActiveOutbox.configuration.outbox_mapping[namespace&.underscore] end def default_outbox_mapping + # byebug ActiveOutbox.configuration.outbox_mapping['default'] end diff --git a/spec/lib/active_outbox/outboxable_spec.rb b/spec/lib/active_outbox/outboxable_spec.rb index 603c0a2..ea0eb54 100644 --- a/spec/lib/active_outbox/outboxable_spec.rb +++ b/spec/lib/active_outbox/outboxable_spec.rb @@ -108,6 +108,18 @@ include_examples 'raises an error and does not create neither the record nor the outbox record', ActiveRecord::RecordNotSaved end + + context 'when the ActiveOutbox configuration is not set' do + before do + # active_outbox = instance_double(ActiveOutbox) + # allow(ActiveOutbox).to receive(:new).and_return(active_outbox) + allow(ActiveOutbox.configuration).to receive(:outbox_mapping).and_return({ 'default' => nil }) + end + + it 'raises an error' do + expect { save_instance }.to raise_error(ActiveOutbox::OutboxClassNotFoundError) + end + end end context 'when the record could not be created' do diff --git a/spec/support/00_outbox_config.rb b/spec/support/00_outbox_config.rb index 142a043..de1cf4e 100644 --- a/spec/support/00_outbox_config.rb +++ b/spec/support/00_outbox_config.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true ActiveOutbox.configure do |config| + # byebug config.outbox_mapping.merge!( 'default' => 'Outbox' )