Create default path for brouillons procedures
This commit is contained in:
parent
44f28ec565
commit
f96d1b1823
2 changed files with 41 additions and 0 deletions
|
@ -0,0 +1,17 @@
|
||||||
|
namespace :after_party do
|
||||||
|
desc 'Deployment task: create_default_path_for_brouillons'
|
||||||
|
task create_default_path_for_brouillons: :environment do
|
||||||
|
puts "Running deploy task 'create_default_path_for_brouillons'"
|
||||||
|
|
||||||
|
# Put your task implementation HERE.
|
||||||
|
|
||||||
|
Procedure.brouillons.where(path: nil).each do |p|
|
||||||
|
p.path = SecureRandom.uuid
|
||||||
|
p.save
|
||||||
|
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: '20190306172842'
|
||||||
|
end # task :create_default_path_for_brouillons
|
||||||
|
end # namespace :after_party
|
|
@ -0,0 +1,24 @@
|
||||||
|
describe '20190306172842_create_default_path_for_brouillons.rake' do
|
||||||
|
let(:rake_task) { Rake::Task['after_party:create_default_path_for_brouillons'] }
|
||||||
|
|
||||||
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
let!(:procedure) { create(:procedure, administrateur: administrateur) }
|
||||||
|
let!(:procedure2) { create(:simple_procedure, administrateur: administrateur) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
rake_task.invoke
|
||||||
|
administrateur.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
after { rake_task.reenable }
|
||||||
|
|
||||||
|
it 'create a path for his brouillon procedure' do
|
||||||
|
expect(administrateur.procedures.brouillon.count).to eq(1)
|
||||||
|
expect(administrateur.procedures.brouillon.first.path).not_to eq(nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not change the path of his published procedure' do
|
||||||
|
expect(administrateur.procedures.publiee.count).to eq(1)
|
||||||
|
expect(administrateur.procedures.publiee.first.path).to eq(procedure2.path)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue