Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
journaled (6.2.3)
journaled (6.2.4)
activejob
activerecord
activesupport
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_7_2.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
journaled (6.2.3)
journaled (6.2.4)
activejob
activerecord
activesupport
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_8_0.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
journaled (6.2.3)
journaled (6.2.4)
activejob
activerecord
activesupport
Expand Down
2 changes: 2 additions & 0 deletions lib/journaled/outbox/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class TableNotFoundError < StandardError; end
# @param ** [Hash] Additional options (ignored, for interface compatibility)
# @return [void]
def self.deliver(events:, **)
return unless Journaled.enabled?

check_table_exists!

records = events.map do |event|
Expand Down
2 changes: 1 addition & 1 deletion lib/journaled/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Journaled
VERSION = "6.2.3"
VERSION = "6.2.4"
end
22 changes: 22 additions & 0 deletions spec/lib/journaled/outbox/adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,28 @@
end

describe '.deliver' do
context 'when Journaled is disabled' do
before do
allow(Journaled).to receive(:enabled?).and_return(false)
end

it 'does not persist any events' do
expect {
described_class.deliver(events:, enqueue_opts:)
}.not_to change { Journaled::Outbox::Event.count }
end

it 'does not check for table existence' do
expect(described_class).not_to receive(:check_table_exists!)
described_class.deliver(events:, enqueue_opts:)
end
end

context 'when tables exist' do
before do
allow(Journaled).to receive(:enabled?).and_return(true)
end

it 'creates database event records' do
expect {
described_class.deliver(events:, enqueue_opts:)
Expand Down Expand Up @@ -119,6 +140,7 @@

context 'when tables do not exist' do
before do
allow(Journaled).to receive(:enabled?).and_return(true)
allow(Journaled::Outbox::Event).to receive(:table_exists?).and_return(false)
end

Expand Down
1 change: 1 addition & 0 deletions spec/models/journaled/writer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ def fake_event(num)
context 'with Outbox::Adapter' do
before do
skip "Outbox tests require PostgreSQL" unless ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
allow(Journaled).to receive(:enabled?).and_return(true)
end

around do |example|
Expand Down
Loading