populate zones
This commit is contained in:
parent
219eaf0d5e
commit
5b8d872b6e
3 changed files with 65 additions and 0 deletions
37
config/zones.yml
Normal file
37
config/zones.yml
Normal file
|
@ -0,0 +1,37 @@
|
|||
ministeres:
|
||||
- MAA:
|
||||
label: "Ministère de l'Agriculture et de l'Alimentation"
|
||||
- MC:
|
||||
label: "Ministère de la Culture"
|
||||
- MAS:
|
||||
label: "Ministère des Solidarités et de la Santé"
|
||||
- MTEI:
|
||||
label: "Ministère du Travail"
|
||||
- MEAE:
|
||||
label: "Ministère de l'Europe et des Affaires étrangères"
|
||||
- MEF:
|
||||
label: "Ministère de l'Économie, des Finances et de la Relance"
|
||||
- MJS:
|
||||
label: "Ministère de la Jeunesse et des Sports"
|
||||
- EN:
|
||||
label: "Ministère de l'Éducation nationale, de la Jeunesse et des Sports"
|
||||
- ESR:
|
||||
label: "Ministère de l'Enseignement supérieur, de la Recherche et de l'Innovation"
|
||||
- MI:
|
||||
label: "Ministère de l'Intérieur"
|
||||
- MInArm:
|
||||
label: "Ministère des Armées"
|
||||
- MJ:
|
||||
label: "Ministère de la Justice"
|
||||
- MTES:
|
||||
label: "Ministère de la Transition écologique"
|
||||
- MCTRCT:
|
||||
label: "Ministère de la Cohésion des territoires et des Relations avec les collectivités territoriales"
|
||||
- SPM:
|
||||
label: "Premier ministre"
|
||||
- MER:
|
||||
label: "Ministère de la Mer"
|
||||
- MTFP:
|
||||
label: "Ministère de la Transformation et de la Fonction publiques"
|
||||
- OM:
|
||||
label: "Ministère des Outre-mer"
|
17
lib/tasks/deployment/20211116140232_populate_zones.rake
Normal file
17
lib/tasks/deployment/20211116140232_populate_zones.rake
Normal file
|
@ -0,0 +1,17 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: populate_zones'
|
||||
task populate_zones: :environment do
|
||||
puts "Running deploy task 'populate_zones'"
|
||||
|
||||
Zone.create!(acronym: 'COLLECTIVITE', label: 'Collectivité territoriale')
|
||||
config = Psych.safe_load(File.read(Rails.root.join("config", "zones.yml")))
|
||||
config["ministeres"].each do |ministere|
|
||||
acronym = ministere.keys.first
|
||||
Zone.create!(acronym: acronym, label: ministere["label"])
|
||||
end
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord
|
||||
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
describe '20211116140232_populate_zones' do
|
||||
let(:rake_task) { Rake::Task['after_party:populate_zones'] }
|
||||
subject(:run_task) do
|
||||
rake_task.invoke
|
||||
end
|
||||
|
||||
it 'populates zones' do
|
||||
run_task
|
||||
expect(Zone.find_by(acronym: 'SPM').label).to eq "Premier ministre"
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue