extract ds_opendata_enabled

This commit is contained in:
Christophe Robillard 2022-12-19 16:35:49 +01:00
parent daa4411abe
commit edffd0a7a8
3 changed files with 7 additions and 5 deletions

View file

@ -2,7 +2,7 @@ module DatagouvCronSchedulableConcern
extend ActiveSupport::Concern
class_methods do
def schedulable?
ENV.fetch('OPENDATA_ENABLED', nil) == 'enabled'
Rails.application.config.ds_opendata_enabled
end
end
end

View file

@ -75,6 +75,8 @@ module TPS
status_visible_duration: 6000
}
config.ds_opendata_enabled = ENV.fetch('OPENDATA_ENABLED', nil) == 'enabled'
config.skylight.probes += [:graphql]
# Custom Configuration

View file

@ -27,15 +27,15 @@ RSpec.describe Cron::Datagouv::ExportAndPublishDemarchesPubliquesJob, type: :job
end
describe '#schedulable?' do
context "when ENV['OPENDATA_ENABLED'] == 'enabled'" do
context "when Rails.application.config.ds_opendata_enabled == 'enabled'" do
it 'is schedulable' do
ENV['OPENDATA_ENABLED'] = 'enabled'
Rails.application.config.ds_opendata_enabled = 'enabled'
expect(Cron::Datagouv::ExportAndPublishDemarchesPubliquesJob.schedulable?).to be_truthy
end
end
context "when ENV['OPENDATA_ENABLED'] != 'enabled'" do
context "when Rails.application.config.ds_opendata_enabled != 'enabled'" do
it 'is schedulable' do
ENV['OPENDATA_ENABLED'] = nil
Rails.application.config.ds_opendata_enabled = nil
expect(Cron::Datagouv::ExportAndPublishDemarchesPubliquesJob.schedulable?).to be_falsy
end
end