From 84c648eef0af61281cc5043a0c1c2801ced00c4a Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Tue, 14 Dec 2021 14:33:19 +0100 Subject: [PATCH] manual task for populating zones --- .../20211116140232_populate_zones.rake | 17 ----------------- lib/tasks/populate_zones.rake | 10 ++++++++++ .../20211116140232_populate_zones_spec.rb | 11 ----------- spec/lib/tasks/populate_zones_spec.rb | 11 +++++++++++ 4 files changed, 21 insertions(+), 28 deletions(-) delete mode 100644 lib/tasks/deployment/20211116140232_populate_zones.rake create mode 100644 lib/tasks/populate_zones.rake delete mode 100644 spec/lib/tasks/deployment/20211116140232_populate_zones_spec.rb create mode 100644 spec/lib/tasks/populate_zones_spec.rb diff --git a/lib/tasks/deployment/20211116140232_populate_zones.rake b/lib/tasks/deployment/20211116140232_populate_zones.rake deleted file mode 100644 index 4d97f86a5..000000000 --- a/lib/tasks/deployment/20211116140232_populate_zones.rake +++ /dev/null @@ -1,17 +0,0 @@ -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 diff --git a/lib/tasks/populate_zones.rake b/lib/tasks/populate_zones.rake new file mode 100644 index 000000000..d6f660884 --- /dev/null +++ b/lib/tasks/populate_zones.rake @@ -0,0 +1,10 @@ +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 +end diff --git a/spec/lib/tasks/deployment/20211116140232_populate_zones_spec.rb b/spec/lib/tasks/deployment/20211116140232_populate_zones_spec.rb deleted file mode 100644 index 9018fb96f..000000000 --- a/spec/lib/tasks/deployment/20211116140232_populate_zones_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -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 diff --git a/spec/lib/tasks/populate_zones_spec.rb b/spec/lib/tasks/populate_zones_spec.rb new file mode 100644 index 000000000..e3cbd0ab1 --- /dev/null +++ b/spec/lib/tasks/populate_zones_spec.rb @@ -0,0 +1,11 @@ +describe 'populate_zones' do + let(:rake_task) { Rake::Task['populate_zones'] } + subject(:run_task) do + rake_task.invoke + end + + it 'populates zones' do + run_task + expect(Zone.find_by(acronym: 'PM').label).to eq "Premier ministre" + end +end