From f1809c4dd3ca473cf3d022f890db209b62d6e73e Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sun, 5 Mar 2023 13:53:27 +0100 Subject: [PATCH 1/3] Disable fog in tests --- .../settings/profile_picture_controller_spec.rb | 7 +++++++ spec/lib/use_case/data_export/user_spec.rb | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/spec/controllers/settings/profile_picture_controller_spec.rb b/spec/controllers/settings/profile_picture_controller_spec.rb index 6e1bc692..d36168c7 100644 --- a/spec/controllers/settings/profile_picture_controller_spec.rb +++ b/spec/controllers/settings/profile_picture_controller_spec.rb @@ -5,6 +5,13 @@ require "rails_helper" describe Settings::ProfilePictureController, type: :controller do describe "#update" do subject { patch :update, params: { user: avatar_params } } + + before do + stub_const("APP_CONFIG", { + "fog" => {} + }) + end + let(:avatar_params) do { profile_picture: fixture_file_upload("banana_racc.jpg", "image/jpeg") diff --git a/spec/lib/use_case/data_export/user_spec.rb b/spec/lib/use_case/data_export/user_spec.rb index 9f01e1ef..91ee7e08 100644 --- a/spec/lib/use_case/data_export/user_spec.rb +++ b/spec/lib/use_case/data_export/user_spec.rb @@ -3,6 +3,12 @@ require "rails_helper" describe UseCase::DataExport::User, :data_export do + before do + stub_const("APP_CONFIG", { + "fog" => {} + }) + end + let(:user_params) do { email: "fizzyraccoon@bsnss.biz", From 36c52db8b97eb43271b79c219bab4450b7cf7393 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sun, 5 Mar 2023 14:06:16 +0100 Subject: [PATCH 2/3] Fix lint errors --- .../settings/profile_picture_controller_spec.rb | 8 ++++---- spec/lib/use_case/data_export/user_spec.rb | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/controllers/settings/profile_picture_controller_spec.rb b/spec/controllers/settings/profile_picture_controller_spec.rb index d36168c7..77fe078e 100644 --- a/spec/controllers/settings/profile_picture_controller_spec.rb +++ b/spec/controllers/settings/profile_picture_controller_spec.rb @@ -8,13 +8,13 @@ describe Settings::ProfilePictureController, type: :controller do before do stub_const("APP_CONFIG", { - "fog" => {} - }) + "fog" => {}, + }) end let(:avatar_params) do { - profile_picture: fixture_file_upload("banana_racc.jpg", "image/jpeg") + profile_picture: fixture_file_upload("banana_racc.jpg", "image/jpeg"), } end @@ -25,7 +25,7 @@ describe Settings::ProfilePictureController, type: :controller do it "enqueues a Sidekiq job to process the uploaded profile picture" do subject - expect(::CarrierWave::Workers::ProcessAsset).to have_enqueued_sidekiq_job("User", user.id.to_s, "profile_picture") + expect(CarrierWave::Workers::ProcessAsset).to have_enqueued_sidekiq_job("User", user.id.to_s, "profile_picture") end it "redirects to the edit_user_profile page" do diff --git a/spec/lib/use_case/data_export/user_spec.rb b/spec/lib/use_case/data_export/user_spec.rb index 91ee7e08..293f70fe 100644 --- a/spec/lib/use_case/data_export/user_spec.rb +++ b/spec/lib/use_case/data_export/user_spec.rb @@ -5,8 +5,8 @@ require "rails_helper" describe UseCase::DataExport::User, :data_export do before do stub_const("APP_CONFIG", { - "fog" => {} - }) + "fog" => {}, + }) end let(:user_params) do @@ -41,8 +41,8 @@ describe UseCase::DataExport::User, :data_export do location: "Binland", motivation_header: "", website: "https://retrospring.net", - allow_long_questions: true - } + allow_long_questions: true, + }, } end @@ -97,7 +97,7 @@ describe UseCase::DataExport::User, :data_export do privacy_noindex: false, sharing_enabled: false, sharing_autoclose: false, - sharing_custom_url: nil + sharing_custom_url: nil, }, profile: { display_name: "Fizzy Raccoon", @@ -108,12 +108,12 @@ describe UseCase::DataExport::User, :data_export do created_at: user.profile.created_at.as_json, updated_at: user.profile.updated_at.as_json, anon_display_name: nil, - allow_long_questions: true + allow_long_questions: true, }, roles: { administrator: false, - moderator: false - } + moderator: false, + }, } ) end From f3c7132103f6b0f6bd2584c8dedbec2b6a3577ef Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sun, 5 Mar 2023 20:37:25 +0100 Subject: [PATCH 3/3] Allow use of `USE_FOG_IN_TESTS` env var --- .../settings/profile_picture_controller_spec.rb | 8 +++++--- spec/lib/use_case/data_export/user_spec.rb | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/spec/controllers/settings/profile_picture_controller_spec.rb b/spec/controllers/settings/profile_picture_controller_spec.rb index 77fe078e..727e8f61 100644 --- a/spec/controllers/settings/profile_picture_controller_spec.rb +++ b/spec/controllers/settings/profile_picture_controller_spec.rb @@ -7,9 +7,11 @@ describe Settings::ProfilePictureController, type: :controller do subject { patch :update, params: { user: avatar_params } } before do - stub_const("APP_CONFIG", { - "fog" => {}, - }) + if ENV["USE_FOG_IN_TESTS"].blank? + stub_const("APP_CONFIG", { + "fog" => {}, + }) + end end let(:avatar_params) do diff --git a/spec/lib/use_case/data_export/user_spec.rb b/spec/lib/use_case/data_export/user_spec.rb index 293f70fe..99d5d09e 100644 --- a/spec/lib/use_case/data_export/user_spec.rb +++ b/spec/lib/use_case/data_export/user_spec.rb @@ -4,9 +4,11 @@ require "rails_helper" describe UseCase::DataExport::User, :data_export do before do - stub_const("APP_CONFIG", { - "fog" => {}, - }) + if ENV["USE_FOG_IN_TESTS"].blank? + stub_const("APP_CONFIG", { + "fog" => {}, + }) + end end let(:user_params) do