Make sure Procedure.path is not null in our data (#4049)
Fait en sorte que Procedure.path soit toujours présent en base
This commit is contained in:
commit
e459eca16d
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_private: [:drop_down_list, types_de_champ: :drop_down_list]
|
||||
}, &method(:clone_attachments))
|
||||
procedure.path = nil
|
||||
procedure.path = SecureRandom.uuid
|
||||
procedure.aasm_state = :brouillon
|
||||
procedure.test_started_at = nil
|
||||
procedure.archived_at = nil
|
||||
|
@ -505,12 +505,12 @@ class Procedure < ApplicationRecord
|
|||
end
|
||||
|
||||
def after_archive
|
||||
update!(archived_at: Time.zone.now, path: nil)
|
||||
update!(archived_at: Time.zone.now, path: SecureRandom.uuid)
|
||||
end
|
||||
|
||||
def after_hide
|
||||
now = Time.zone.now
|
||||
update!(hidden_at: now, path: nil)
|
||||
update!(hidden_at: now, path: SecureRandom.uuid)
|
||||
dossiers.update_all(hidden_at: now)
|
||||
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
|
||||
expect(procedure2.archivee?).to be_truthy
|
||||
expect(procedure2.path).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -690,19 +690,9 @@ describe Procedure do
|
|||
|
||||
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") }
|
||||
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
|
||||
it { is_expected.to eq("dossiers_#{procedure.path}_2018-01-02_23-11.csv") }
|
||||
end
|
||||
|
||||
describe '#new_dossier' do
|
||||
|
|
Loading…
Reference in a new issue