From 91bc53434c00873659b83d8512c4ef87bf981f7a Mon Sep 17 00:00:00 2001 From: Alexandru Emil Lupu Date: Thu, 1 Aug 2024 00:45:26 +0300 Subject: [PATCH] Fix failing specs --- decidim-core/spec/lib/decidim_spec.rb | 3 ++- decidim-core/spec/lib/organization_settings_spec.rb | 4 +++- decidim-core/spec/uploaders/application_uploader_spec.rb | 3 ++- .../lib/decidim/generators/app_templates/initializer.rb | 8 ++++---- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/decidim-core/spec/lib/decidim_spec.rb b/decidim-core/spec/lib/decidim_spec.rb index d5104bf2c5924..d0a81204d44c0 100644 --- a/decidim-core/spec/lib/decidim_spec.rb +++ b/decidim-core/spec/lib/decidim_spec.rb @@ -41,9 +41,10 @@ describe ".force_ssl" do let!(:orig_force_ssl) { described_class.force_ssl } let(:rails_env) { "test" } + let(:env) { ActiveSupport::EnvironmentInquirer.new(rails_env) } before do - allow(Rails).to receive(:env).and_return(rails_env) + allow(Rails).to receive(:env).and_return(env) load "#{Decidim::Core::Engine.root}/lib/decidim/core.rb" end diff --git a/decidim-core/spec/lib/organization_settings_spec.rb b/decidim-core/spec/lib/organization_settings_spec.rb index 4b4faca35cf66..d8683f403fb82 100644 --- a/decidim-core/spec/lib/organization_settings_spec.rb +++ b/decidim-core/spec/lib/organization_settings_spec.rb @@ -148,7 +148,9 @@ module Decidim let(:maximum_attachment_size) { 20 } before do - ENV["DECIDIM_MAXIMUM_ATTACHMENT_SIZE"] = maximum_attachment_size + allow(ENV).to receive(:fetch).and_call_original + allow(ENV).to receive(:fetch).with("DECIDIM_MAXIMUM_ATTACHMENT_SIZE", nil).and_return("#{maximum_attachment_size}") + # defaults method is memoized, we need to reset it to make sure it uses the stubbed values described_class.instance_variable_set(:@defaults, nil) end diff --git a/decidim-core/spec/uploaders/application_uploader_spec.rb b/decidim-core/spec/uploaders/application_uploader_spec.rb index b0f9519fffcbd..a0c76161736ad 100644 --- a/decidim-core/spec/uploaders/application_uploader_spec.rb +++ b/decidim-core/spec/uploaders/application_uploader_spec.rb @@ -195,7 +195,8 @@ module Decidim before do allow(Rails.env).to receive(:development?).and_return(false) allow(Rails.env).to receive(:test?).and_return(false) - ENV["STORAGE_CDN_HOST"] = cdn_host + allow(ENV).to receive(:fetch).and_call_original + allow(ENV).to receive(:fetch).with("STORAGE_CDN_HOST", nil).and_return(cdn_host) end it "returns a URL containing the CDN configurations" do diff --git a/decidim-generators/lib/decidim/generators/app_templates/initializer.rb b/decidim-generators/lib/decidim/generators/app_templates/initializer.rb index 62ab8667c7f6c..fe1de3860af78 100644 --- a/decidim-generators/lib/decidim/generators/app_templates/initializer.rb +++ b/decidim-generators/lib/decidim/generators/app_templates/initializer.rb @@ -2,7 +2,7 @@ Decidim.configure do |config| # The name of the application - config.application_name = Decidim::Env.new("DECIDIM_APPLICATION_NAME", "My Application Name").to_json + config.application_name = Decidim::Env.new("DECIDIM_APPLICATION_NAME", "My Application Name").to_s # The email that will be used as sender in all emails from Decidim config.mailer_sender = Decidim::Env.new("DECIDIM_MAILER_SENDER", "change-me@example.org").to_s @@ -293,12 +293,12 @@ config.etherpad = { server: ENV.fetch("ETHERPAD_SERVER", nil), api_key: ENV.fetch("ETHERPAD_API_KEY", nil), - api_version: Decidim::Env.new("ETHERPAD_API_VERSION", "1.2.1") + api_version: Decidim::Env.new("ETHERPAD_API_VERSION", "1.2.1").value } end # Sets Decidim::Exporters::CSV's default column separator - config.default_csv_col_sep = Decidim::Env.new("DECIDIM_DEFAULT_CSV_COL_SEP", ";").to_json + config.default_csv_col_sep = Decidim::Env.new("DECIDIM_DEFAULT_CSV_COL_SEP", ";").value # The list of roles a user can have, not considering the space-specific roles. # config.user_roles = %w(admin user_manager) @@ -346,7 +346,7 @@ # config.machine_translation_service = "MyTranslationService" # Defines the social networking services used for social sharing - config.social_share_services = Decidim::Env.new("DECIDIM_SOCIAL_SHARE_SERVICES", "X, Facebook, WhatsApp, Telegram").to_array.to_json + config.social_share_services = Decidim::Env.new("DECIDIM_SOCIAL_SHARE_SERVICES", "X, Facebook, WhatsApp, Telegram").to_array # Defines the name of the cookie used to check if the user allows Decidim to # set cookies.