-
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow configuration of Rails queue adapter with
:good_job
(#28)
- Loading branch information
1 parent
651dda3
commit 75e1728
Showing
7 changed files
with
81 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module ActiveJob | ||
module QueueAdapters | ||
class GoodJobAdapter < GoodJob::Adapter | ||
def initialize | ||
if Rails.env.development? || Rails.env.test? | ||
super(inline: true) | ||
else | ||
super(inline: false) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'rails_helper' | ||
|
||
describe ActiveJob::QueueAdapters::GoodJobAdapter do | ||
it 'inherits from GoodJob::Adapter' do | ||
expect(described_class).to be < GoodJob::Adapter | ||
end | ||
|
||
it 'allows usage of ActiveJob symbol' do | ||
ActiveJob::Base.queue_adapter = :good_job | ||
expect(ActiveJob::Base.queue_adapter).to be_a described_class | ||
end | ||
|
||
describe '#initialize' do | ||
before { allow(Rails.env).to receive(:test?).and_return(false) } | ||
|
||
context 'when in development environment' do | ||
before { allow(Rails.env).to receive(:development?).and_return(true) } | ||
|
||
it 'runs inline' do | ||
adapter = described_class.new | ||
expect(adapter.inline?).to eq true | ||
end | ||
end | ||
|
||
context 'when in test environment' do | ||
before { allow(Rails.env).to receive(:test?).and_return(true) } | ||
|
||
it 'runs inline' do | ||
adapter = described_class.new | ||
expect(adapter.inline?).to eq true | ||
end | ||
end | ||
|
||
context 'when in production environment' do | ||
before { allow(Rails.env).to receive(:production?).and_return(true) } | ||
|
||
it 'runs in normal mode' do | ||
adapter = described_class.new | ||
expect(adapter.inline?).to eq false | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
RSpec.configure do |config| | ||
config.around do |example| | ||
original_adapter = ActiveJob::Base.queue_adapter | ||
example.run | ||
ActiveJob::Base.queue_adapter = original_adapter | ||
end | ||
end |