spec: only load tasks once

When a task is loaded several times, a single call of `task.invoke`
will run the task several times too.

This made `add_annotion_privee_to_procedure_spec` fail when it wasn't
the first task being tested.
This commit is contained in:
Pierre de La Morinerie 2018-06-20 09:29:02 +00:00
parent 90b1887702
commit 9f502c536b
4 changed files with 2 additions and 4 deletions

View file

@ -10,7 +10,6 @@ describe '2018_03_06_clean_html_textareas#clean' do
before do
Timecop.freeze(champ_date) { champ }
TPS::Application.load_tasks
Timecop.freeze(rake_date) { rake_task.invoke }
champ.reload
end

View file

@ -10,7 +10,6 @@ describe '2018_03_29_remove_code_tags_from_mail_templates#clean' do
let!(:dirty_without_continuation_mail) { create(:without_continuation_mail, body: "<h1>Salut</h1><br>Voici ton email avec une balise <code>--balise--</code>") }
before do
TPS::Application.load_tasks
rake_task.invoke
dirty_closed_mail.reload
dirty_initiated_mail.reload

View file

@ -24,8 +24,6 @@ describe '2018_05_14_add_annotation_privee_to_procedure' do
let!(:dossier) { Dossier.create(procedure: procedure, user: user, state: 'brouillon') }
let(:rake_task) { Rake::Task['2018_05_14_add_annotation_privee_to_procedure:add'] }
before(:all) { TPS::Application.load_tasks }
before do
ENV['PROCEDURE_ID'] = procedure.id.to_s
rake_task.invoke

View file

@ -69,6 +69,8 @@ end
DatabaseCleaner.strategy = :transaction
TPS::Application.load_tasks
SIADETOKEN = :valid_token if !defined? SIADETOKEN
include Warden::Test::Helpers