Make sure Procedure.path is not null in our data
This commit is contained in:
parent
8bb4ccefeb
commit
b066ccbc89
4 changed files with 23 additions and 16 deletions
|
@ -216,7 +216,7 @@ class Procedure < ApplicationRecord
|
||||||
types_de_champ: [:drop_down_list, types_de_champ: :drop_down_list],
|
types_de_champ: [:drop_down_list, types_de_champ: :drop_down_list],
|
||||||
types_de_champ_private: [:drop_down_list, types_de_champ: :drop_down_list]
|
types_de_champ_private: [:drop_down_list, types_de_champ: :drop_down_list]
|
||||||
}, &method(:clone_attachments))
|
}, &method(:clone_attachments))
|
||||||
procedure.path = nil
|
procedure.path = SecureRandom.uuid
|
||||||
procedure.aasm_state = :brouillon
|
procedure.aasm_state = :brouillon
|
||||||
procedure.test_started_at = nil
|
procedure.test_started_at = nil
|
||||||
procedure.archived_at = nil
|
procedure.archived_at = nil
|
||||||
|
@ -505,12 +505,12 @@ class Procedure < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_archive
|
def after_archive
|
||||||
update!(archived_at: Time.zone.now, path: nil)
|
update!(archived_at: Time.zone.now, path: SecureRandom.uuid)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_hide
|
def after_hide
|
||||||
now = Time.zone.now
|
now = Time.zone.now
|
||||||
update!(hidden_at: now, path: nil)
|
update!(hidden_at: now, path: SecureRandom.uuid)
|
||||||
dossiers.update_all(hidden_at: now)
|
dossiers.update_all(hidden_at: now)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
namespace :after_party do
|
||||||
|
desc 'Deployment task: create_dummy_paths_for_archived_and_hidden_procedures'
|
||||||
|
task create_dummy_paths_for_archived_and_hidden_procedures: :environment do
|
||||||
|
puts "Running deploy task 'create_dummy_paths_for_archived_procedures'"
|
||||||
|
|
||||||
|
Procedure.unscoped.archivees.where(path: nil).each do |p|
|
||||||
|
p.update_column(:path, SecureRandom.uuid)
|
||||||
|
end
|
||||||
|
|
||||||
|
Procedure.unscoped.hidden.where(path: nil).each do |p|
|
||||||
|
p.update_column(:path, SecureRandom.uuid)
|
||||||
|
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: '20190704133852'
|
||||||
|
end
|
||||||
|
end
|
|
@ -372,7 +372,6 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
|
|
||||||
it 'archive previous procedure' do
|
it 'archive previous procedure' do
|
||||||
expect(procedure2.archivee?).to be_truthy
|
expect(procedure2.archivee?).to be_truthy
|
||||||
expect(procedure2.path).to be_nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -690,19 +690,9 @@ describe Procedure do
|
||||||
|
|
||||||
subject { procedure.export_filename(:csv) }
|
subject { procedure.export_filename(:csv) }
|
||||||
|
|
||||||
context "with a path" do
|
let(:procedure) { create(:procedure, :published) }
|
||||||
let(:procedure) { create(:procedure, :published) }
|
|
||||||
|
|
||||||
it { is_expected.to eq("dossiers_#{procedure.path}_2018-01-02_23-11.csv") }
|
it { is_expected.to eq("dossiers_#{procedure.path}_2018-01-02_23-11.csv") }
|
||||||
end
|
|
||||||
|
|
||||||
context "without a path" do
|
|
||||||
let(:procedure) { create(:procedure, :archived) }
|
|
||||||
|
|
||||||
it do
|
|
||||||
is_expected.to eq("dossiers_procedure-#{procedure.id}_2018-01-02_23-11.csv")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#new_dossier' do
|
describe '#new_dossier' do
|
||||||
|
|
Loading…
Add table
Reference in a new issue