Extract method to stub secrets in tests
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -14,6 +14,7 @@ module CommonActions
|
||||
include Polls
|
||||
include Proposals
|
||||
include RemoteCensusMock
|
||||
include Secrets
|
||||
include Tags
|
||||
include Translations
|
||||
include Users
|
||||
|
||||
7
spec/support/common_actions/secrets.rb
Normal file
7
spec/support/common_actions/secrets.rb
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user