From 9f502c536b49f9ab5fdb30f81ec2481c715f5d88 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 20 Jun 2018 09:29:02 +0000 Subject: [PATCH] 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. --- spec/lib/rake/2018_03_06_clean_html_textareas_spec.rb | 1 - .../2018_03_29_remove_code_tags_from_mail_templates_spec.rb | 1 - .../rake/2018_05_14_add_annotation_privee_to_procedure_spec.rb | 2 -- spec/spec_helper.rb | 2 ++ 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/spec/lib/rake/2018_03_06_clean_html_textareas_spec.rb b/spec/lib/rake/2018_03_06_clean_html_textareas_spec.rb index e1790f6f4..cff7056d0 100644 --- a/spec/lib/rake/2018_03_06_clean_html_textareas_spec.rb +++ b/spec/lib/rake/2018_03_06_clean_html_textareas_spec.rb @@ -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 diff --git a/spec/lib/rake/2018_03_29_remove_code_tags_from_mail_templates_spec.rb b/spec/lib/rake/2018_03_29_remove_code_tags_from_mail_templates_spec.rb index 402d6c8fa..20667b06d 100644 --- a/spec/lib/rake/2018_03_29_remove_code_tags_from_mail_templates_spec.rb +++ b/spec/lib/rake/2018_03_29_remove_code_tags_from_mail_templates_spec.rb @@ -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: "

Salut


Voici ton email avec une balise --balise--") } before do - TPS::Application.load_tasks rake_task.invoke dirty_closed_mail.reload dirty_initiated_mail.reload diff --git a/spec/lib/rake/2018_05_14_add_annotation_privee_to_procedure_spec.rb b/spec/lib/rake/2018_05_14_add_annotation_privee_to_procedure_spec.rb index 70d377cf6..2817c4797 100644 --- a/spec/lib/rake/2018_05_14_add_annotation_privee_to_procedure_spec.rb +++ b/spec/lib/rake/2018_05_14_add_annotation_privee_to_procedure_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4b8773121..f532af613 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -69,6 +69,8 @@ end DatabaseCleaner.strategy = :transaction +TPS::Application.load_tasks + SIADETOKEN = :valid_token if !defined? SIADETOKEN include Warden::Test::Helpers