Browse Source

Stub some credentials (#2857)

pull/2860/head
kosiakkatrina 1 month ago committed by GitHub
parent
commit
8594561a18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      spec/mailers/devise_notify_mailer_spec.rb
  2. 1
      spec/models/user_spec.rb

11
spec/mailers/devise_notify_mailer_spec.rb

@ -36,8 +36,11 @@ RSpec.describe DeviseNotifyMailer do
end
context "when the email domain is in the allowlist" do
let(:domain) { Rails.application.credentials[:email_allowlist].first }
let(:email) { "test@#{domain}" }
before do
allow(Rails.application.credentials).to receive(:[]).with(:email_allowlist).and_return(["example.com"])
end
let(:email) { "test@example.com" }
it "does send emails" do
expect(notify_client).to receive(:send_email).once
@ -48,10 +51,10 @@ RSpec.describe DeviseNotifyMailer do
context "when notify mailer raises BadRequestError" do
before do
allow(notify_client).to receive(:send_email).and_raise(bad_request_error)
allow(Rails.application.credentials).to receive(:[]).with(:email_allowlist).and_return(["example.com"])
end
let(:domain) { Rails.application.credentials[:email_allowlist].first }
let(:email) { "test@#{domain}" }
let(:email) { "test@example.com" }
it "does not raise an error" do
expect {

1
spec/models/user_spec.rb

@ -300,6 +300,7 @@ RSpec.describe User, type: :model do
context "when the user is in staging environment" do
before do
allow(Rails.env).to receive(:staging?).and_return(true)
allow(Rails.application.credentials).to receive(:[]).with(:staging_role_update_email_allowlist).and_return(["not_one_of_the_examples.com"])
end
context "and the user is not in the staging role update email allowlist" do

Loading…
Cancel
Save