Skip to content

Commit

Permalink
[WIP] - Spec for outbox class not found error
Browse files Browse the repository at this point in the history
  • Loading branch information
santiagodiaz committed Oct 4, 2023
1 parent f2d73e1 commit 857212d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_outbox/outboxable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ def outbox_model_name_from_config

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

Expand Down
12 changes: 12 additions & 0 deletions spec/lib/active_outbox/outboxable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions spec/support/00_outbox_config.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

ActiveOutbox.configure do |config|
# byebug
config.outbox_mapping.merge!(
'default' => 'Outbox'
)
Expand Down

0 comments on commit 857212d

Please sign in to comment.