From edffd0a7a89ec3e3f87ea8f3b217175a239f4b52 Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Mon, 19 Dec 2022 16:35:49 +0100 Subject: [PATCH] extract ds_opendata_enabled --- app/jobs/concerns/datagouv_cron_schedulable_concern.rb | 2 +- config/application.rb | 2 ++ .../export_and_publish_demarches_publiques_job_spec.rb | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/jobs/concerns/datagouv_cron_schedulable_concern.rb b/app/jobs/concerns/datagouv_cron_schedulable_concern.rb index 8541a0722..c1d10114a 100644 --- a/app/jobs/concerns/datagouv_cron_schedulable_concern.rb +++ b/app/jobs/concerns/datagouv_cron_schedulable_concern.rb @@ -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 diff --git a/config/application.rb b/config/application.rb index 9e206a487..792919e98 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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 diff --git a/spec/jobs/cron/datagouv/export_and_publish_demarches_publiques_job_spec.rb b/spec/jobs/cron/datagouv/export_and_publish_demarches_publiques_job_spec.rb index 7ac7eff1b..f12068bb8 100644 --- a/spec/jobs/cron/datagouv/export_and_publish_demarches_publiques_job_spec.rb +++ b/spec/jobs/cron/datagouv/export_and_publish_demarches_publiques_job_spec.rb @@ -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