-
-
Notifications
You must be signed in to change notification settings - Fork 190
/
configuration_spec.rb
55 lines (47 loc) · 1.61 KB
/
configuration_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe GoodJob::Configuration do
describe '#execution_mode' do
context 'when in development' do
before do
allow(Rails).to receive(:env) { "development".inquiry }
end
it 'defaults to :inline' do
configuration = described_class.new({})
expect(configuration.execution_mode).to eq :inline
end
end
context 'when in production' do
before do
allow(Rails).to receive(:env) { "production".inquiry }
end
it 'defaults to :external' do
configuration = described_class.new({})
expect(configuration.execution_mode).to eq :external
end
end
end
describe '#cleanup_preserved_jobs_before_seconds_ago' do
it 'defaults to 86400' do
configuration = described_class.new({})
expect(configuration.cleanup_preserved_jobs_before_seconds_ago).to eq 86400
end
context 'when environment variable is set' do
before do
stub_const 'ENV', ENV.to_hash.merge({ 'GOOD_JOB_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO' => 36000 })
end
context 'when option is given' do
it 'uses option value' do
configuration = described_class.new({ before_seconds_ago: 10000 })
expect(configuration.cleanup_preserved_jobs_before_seconds_ago).to eq 10000
end
end
context 'when option is not given' do
it 'uses environment variable' do
configuration = described_class.new({})
expect(configuration.cleanup_preserved_jobs_before_seconds_ago).to eq 36000
end
end
end
end
end