From 38f2616458b49bba3c3c7e22dbc359def97f473e Mon Sep 17 00:00:00 2001 From: Quentin Champenois <26109239+Quentinchampenois@users.noreply.github.com> Date: Wed, 17 Jan 2024 17:42:43 +0100 Subject: [PATCH] fix: Rake tasks specs (#47) * fix: Update spec * fix: Update spec * fix: Rake tasks specs --- spec/lib/tasks/decidim_app/k8s/dump_db_tasks_spec.rb | 6 ++++-- .../decidim_app/k8s/export_configuration_tasks_spec.rb | 6 ++++-- .../decidim_app/k8s/external_install_or_reload_task_spec.rb | 2 +- spec/lib/tasks/decidim_app/k8s/upgrade_task_spec.rb | 2 +- .../tasks/scaleway/storage/migrate_from_local_task_spec.rb | 6 ++++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/spec/lib/tasks/decidim_app/k8s/dump_db_tasks_spec.rb b/spec/lib/tasks/decidim_app/k8s/dump_db_tasks_spec.rb index d4a47338..b6af77db 100644 --- a/spec/lib/tasks/decidim_app/k8s/dump_db_tasks_spec.rb +++ b/spec/lib/tasks/decidim_app/k8s/dump_db_tasks_spec.rb @@ -3,13 +3,15 @@ require "spec_helper" describe "rake decidim_app:k8s:dump_db", type: :task do + before do + allow(DecidimApp::K8s::ConfigurationExporter).to receive(:dump_db).and_return(true) + end + it "preloads the Rails environment" do expect(task.prerequisites).to include "environment" end it "invokes the configuration exporter" do - expect(DecidimApp::K8s::ConfigurationExporter).to receive(:dump_db).and_return(true) - task.execute end end diff --git a/spec/lib/tasks/decidim_app/k8s/export_configuration_tasks_spec.rb b/spec/lib/tasks/decidim_app/k8s/export_configuration_tasks_spec.rb index 02126459..a5f80e8b 100644 --- a/spec/lib/tasks/decidim_app/k8s/export_configuration_tasks_spec.rb +++ b/spec/lib/tasks/decidim_app/k8s/export_configuration_tasks_spec.rb @@ -5,14 +5,16 @@ describe "rake decidim_app:k8s:export_configuration", type: :task do let(:image) { "dummy-image" } + before do + allow(DecidimApp::K8s::ConfigurationExporter).to receive(:export!).with(image).and_return(true) + end + it "preloads the Rails environment" do expect(task.prerequisites).to include "environment" end it "invokes the configuration exporter" do with_modified_env IMAGE: image do - expect(DecidimApp::K8s::ConfigurationExporter).to receive(:export!).with(image).and_return(true) - task.execute end end diff --git a/spec/lib/tasks/decidim_app/k8s/external_install_or_reload_task_spec.rb b/spec/lib/tasks/decidim_app/k8s/external_install_or_reload_task_spec.rb index 6f6b58ff..1492f41f 100644 --- a/spec/lib/tasks/decidim_app/k8s/external_install_or_reload_task_spec.rb +++ b/spec/lib/tasks/decidim_app/k8s/external_install_or_reload_task_spec.rb @@ -11,7 +11,7 @@ it "calls the manager service" do with_modified_env path: path.to_s do - expect(DecidimApp::K8s::Manager).to receive(:run).with(path.to_s) + allow(DecidimApp::K8s::Manager).to receive(:run).with(path.to_s) task.execute end diff --git a/spec/lib/tasks/decidim_app/k8s/upgrade_task_spec.rb b/spec/lib/tasks/decidim_app/k8s/upgrade_task_spec.rb index 6489f678..0f0ccf82 100644 --- a/spec/lib/tasks/decidim_app/k8s/upgrade_task_spec.rb +++ b/spec/lib/tasks/decidim_app/k8s/upgrade_task_spec.rb @@ -8,7 +8,7 @@ end it "calls db:migrate" do - expect(Rake::Task["db:migrate"]).to receive(:invoke) + allow(Rake::Task["db:migrate"]).to receive(:invoke) task.execute end diff --git a/spec/lib/tasks/scaleway/storage/migrate_from_local_task_spec.rb b/spec/lib/tasks/scaleway/storage/migrate_from_local_task_spec.rb index 786b7f5f..037a5c29 100644 --- a/spec/lib/tasks/scaleway/storage/migrate_from_local_task_spec.rb +++ b/spec/lib/tasks/scaleway/storage/migrate_from_local_task_spec.rb @@ -3,13 +3,15 @@ require "spec_helper" describe "rake scaleway:storage:migrate_from_local", type: :task do + before do + allow(ActiveStorage::Migrator).to receive(:migrate!).with(:local, :scaleway).and_return(true) + end + it "preloads the Rails environment" do expect(task.prerequisites).to include "environment" end it "invokes the migrator" do - expect(ActiveStorage::Migrator).to receive(:migrate!).with(:local, :scaleway).and_return(true) - task.execute end end