diff --git a/spec/components/account/sign_in_info_component_spec.rb b/spec/components/account/sign_in_info_component_spec.rb index 0e100d2d3..e11d4dd23 100644 --- a/spec/components/account/sign_in_info_component_spec.rb +++ b/spec/components/account/sign_in_info_component_spec.rb @@ -5,9 +5,7 @@ describe Account::SignInInfoComponent do context "Security secret for render last sign in is enabled" do it "shows a sign in info" do - allow(Rails.application).to receive(:secrets).and_return(ActiveSupport::OrderedOptions.new.merge( - security: { last_sign_in: true } - )) + stub_secrets(security: { last_sign_in: true }) render_inline Account::SignInInfoComponent.new(account) diff --git a/spec/mailers/mailer_spec.rb b/spec/mailers/mailer_spec.rb index aed829ae2..4f93ef388 100644 --- a/spec/mailers/mailer_spec.rb +++ b/spec/mailers/mailer_spec.rb @@ -85,12 +85,12 @@ describe Mailer do let(:super_settings) { { address: "super.consul.dev", username: "super" } } before do - allow(Rails.application).to receive(:secrets).and_return(ActiveSupport::OrderedOptions.new.merge( + stub_secrets( smtp_settings: default_settings, tenants: { supermailer: { smtp_settings: super_settings } } - )) + ) end it "does not overwrite the settings for the default tenant" do diff --git a/spec/models/tenant_spec.rb b/spec/models/tenant_spec.rb index e7244c226..f3746f0e7 100644 --- a/spec/models/tenant_spec.rb +++ b/spec/models/tenant_spec.rb @@ -243,10 +243,7 @@ describe Tenant do describe ".current_secrets" do context "same secrets for all tenants" do before do - allow(Rails.application).to receive(:secrets).and_return(ActiveSupport::OrderedOptions.new.merge( - star: "Sun", - volume: "Medium" - )) + stub_secrets(star: "Sun", volume: "Medium") end it "returns the default secrets for the default tenant" do @@ -266,11 +263,11 @@ describe Tenant do context "tenant overwriting secrets" do before do - allow(Rails.application).to receive(:secrets).and_return(ActiveSupport::OrderedOptions.new.merge( + stub_secrets( star: "Sun", volume: "Medium", tenants: { proxima: { star: "Alpha Centauri" }} - )) + ) end it "returns the default secrets for the default tenant" do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b29c9a589..c8d6777c3 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -994,7 +994,7 @@ describe User do context "when secrets are configured" do before do - allow(Rails.application).to receive(:secrets).and_return(ActiveSupport::OrderedOptions.new.merge( + stub_secrets( security: { password_complexity: true }, @@ -1005,7 +1005,7 @@ describe User do } } } - )) + ) end it "uses the general secrets for the main tenant" do @@ -1027,7 +1027,7 @@ describe User do context "when secrets are configured" do before do - allow(Rails.application).to receive(:secrets).and_return(ActiveSupport::OrderedOptions.new.merge( + stub_secrets( security: { lockable: { maximum_attempts: "14" } }, @@ -1038,7 +1038,7 @@ describe User do } } } - )) + ) end it "uses the general secrets for the main tenant" do @@ -1060,7 +1060,7 @@ describe User do context "when secrets are configured" do before do - allow(Rails.application).to receive(:secrets).and_return(ActiveSupport::OrderedOptions.new.merge( + stub_secrets( security: { lockable: { unlock_in: "2" } }, @@ -1071,7 +1071,7 @@ describe User do } } } - )) + ) end it "uses the general secrets for the main tenant" do diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index 355ce41da..22910a166 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -14,6 +14,7 @@ module CommonActions include Polls include Proposals include RemoteCensusMock + include Secrets include Tags include Translations include Users diff --git a/spec/support/common_actions/secrets.rb b/spec/support/common_actions/secrets.rb new file mode 100644 index 000000000..4af9585f4 --- /dev/null +++ b/spec/support/common_actions/secrets.rb @@ -0,0 +1,7 @@ +module Secrets + def stub_secrets(configuration) + allow(Rails.application).to receive(:secrets).and_return( + ActiveSupport::OrderedOptions.new.merge(configuration) + ) + end +end diff --git a/spec/system/users_auth_spec.rb b/spec/system/users_auth_spec.rb index 936b035cd..5c7d35953 100644 --- a/spec/system/users_auth_spec.rb +++ b/spec/system/users_auth_spec.rb @@ -661,9 +661,7 @@ describe "Users" do context "Regular authentication with password complexity enabled" do before do - allow(Rails.application).to receive(:secrets).and_return(ActiveSupport::OrderedOptions.new.merge( - security: { password_complexity: true } - )) + stub_secrets(security: { password_complexity: true }) end context "Sign up" do