I am experiencing a problem that when running the first test of mailers when it makes the first call to the ActionMailer::Base#mail method the test hangs and takes about 10min. Has anyone ever experienced this?
CircleCi image: image: circleci/ruby:2.4.3-node
My test
class Notifier::AccountMailer < NotifierMailer
def welcome(user_id)
@user = User.find user_id
mail(to: @user.email, subject: t('subject.welcome'))
end
end
RSpec.describe Notifier::AccountMailer, type: :mailer do
describe '.welcome' do
let(:user) { build_stubbed(:user) }
let(:mail) { described_class.welcome(1) }
before { allow(User).to receive(:find).and_return(user) }
it 'Send from <notify@my-server.me>' do
expect(mail.from).to eq(['notify@my-server.me'])
end
it 'Send to account e-mail' do
expect(mail.to).to eq([user.email])
end
end
end
The slowness happens only in the first call of the mail method, after everything works normal.