790704ef58
Currently, when running specs, the output of rake tasks is spamming the tests results. This PR configures Rake so that it runs in quiet mode during specs. This disables the internal messages of rake during tests. However our own `puts` also need to be conditionned to the verbosity of rake. Using a simple `rake_puts` helper allows the info messages to be displayed when running the rake task manually, but not during tests. Before: ``` $ bin/rspec spec/lib/rake Randomized with seed 6544 1 Mails::ClosedMail to clean cleaning Mails::ClosedMail #1 1 Mails::InitiatedMail to clean cleaning Mails::InitiatedMail #1 1 Mails::ReceivedMail to clean cleaning Mails::ReceivedMail #1 1 Mails::RefusedMail to clean cleaning Mails::RefusedMail #1 1 Mails::WithoutContinuationMail to clean cleaning Mails::WithoutContinuationMail #1 .....Champ 0/1 .Champ 0/1 . ``` After: ``` $ bin/rspec spec/lib/rake Randomized with seed 6544 ....... ```
52 lines
1,003 B
Ruby
52 lines
1,003 B
Ruby
require Rails.root.join("lib", "tasks", "task_helper")
|
|
|
|
namespace :'2018_06_05_send_new_attestation' do
|
|
task set: :environment do
|
|
ids = [
|
|
20982,
|
|
21262,
|
|
54914,
|
|
59769,
|
|
63747,
|
|
59520,
|
|
21496,
|
|
13386,
|
|
13371,
|
|
14585,
|
|
15307,
|
|
17212,
|
|
16037,
|
|
60403,
|
|
60400,
|
|
20534,
|
|
60123,
|
|
16361,
|
|
16359,
|
|
57147,
|
|
51979,
|
|
49632,
|
|
48628,
|
|
48624,
|
|
22077,
|
|
41103
|
|
]
|
|
|
|
dossiers = ids.map { |id| Dossier.find_by(id: id) }.compact
|
|
|
|
dossiers.each do |dossier|
|
|
attestation = dossier.attestation
|
|
|
|
if attestation
|
|
id = attestation.id
|
|
attestation.destroy
|
|
rake_puts "Attestation #{id} détruite"
|
|
end
|
|
|
|
dossier.attestation = dossier.build_attestation
|
|
|
|
NewAttestationMailer.new_attestation(dossier).deliver_later
|
|
rake_puts "Email envoyé à #{dossier.user.email} pour le dossier #{dossier.id}"
|
|
rake_puts
|
|
end
|
|
end
|
|
end
|