add rake task to update typedechamp
This commit is contained in:
parent
bdbe57debd
commit
c93d17bcaa
2 changed files with 43 additions and 0 deletions
|
@ -0,0 +1,18 @@
|
||||||
|
namespace :after_party do
|
||||||
|
desc 'Deployment task: add_default_skip_validation_to_piece_justificative'
|
||||||
|
task add_default_skip_validation_to_piece_justificative: :environment do
|
||||||
|
puts "Running deploy task 'add_default_skip_validation_to_piece_justificative'"
|
||||||
|
|
||||||
|
tdcs = TypeDeChamp.where(type_champ: TypeDeChamp.type_champs.fetch(:piece_justificative))
|
||||||
|
progress = ProgressReport.new(tdcs.count)
|
||||||
|
tdcs.find_each do |tdc|
|
||||||
|
tdc.update(options: tdc.options&.merge({ :skip_pj_validation => true }) || { :skip_pj_validation => true })
|
||||||
|
progress.inc
|
||||||
|
end
|
||||||
|
progress.finish
|
||||||
|
|
||||||
|
# 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: '20200708101123'
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,25 @@
|
||||||
|
describe '20200708101123_add_default_skip_validation_to_piece_justificative.rake' do
|
||||||
|
let(:rake_task) { Rake::Task['after_party:add_default_skip_validation_to_piece_justificative'] }
|
||||||
|
let!(:pj_type_de_champ) { create(:type_de_champ_piece_justificative) }
|
||||||
|
let!(:text_type_de_champ) { create(:type_de_champ_text) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
rake_task.invoke
|
||||||
|
text_type_de_champ.reload
|
||||||
|
pj_type_de_champ.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
after { rake_task.reenable }
|
||||||
|
|
||||||
|
context 'on a piece_justificative type de champ' do
|
||||||
|
it 'sets the skip_pj_validation option' do
|
||||||
|
expect(pj_type_de_champ.skip_pj_validation).to be_truthy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'on a non piece_justificative type de champ' do
|
||||||
|
it 'does not set the skip_pj_validation option' do
|
||||||
|
expect(text_type_de_champ.skip_pj_validation).to be_blank
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue