dawarich/spec/mailers/users_mailer_spec.rb

70 lines
1.9 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'rails_helper'
2025-08-13 14:25:48 -04:00
RSpec.describe UsersMailer, type: :mailer do
2025-09-18 12:29:46 -04:00
let(:user) { create(:user) }
2025-08-13 14:25:48 -04:00
before do
stub_const('ENV', ENV.to_hash.merge('SMTP_FROM' => 'hi@dawarich.app'))
end
describe 'welcome' do
2025-08-13 14:25:48 -04:00
let(:mail) { UsersMailer.with(user: user).welcome }
it 'renders the headers' do
expect(mail.subject).to eq('Welcome to Dawarich!')
2025-09-18 12:29:46 -04:00
expect(mail.to).to eq([user.email])
2025-08-13 14:25:48 -04:00
end
it 'renders the body' do
2025-09-18 12:29:46 -04:00
expect(mail.body.encoded).to match(user.email)
2025-08-13 14:25:48 -04:00
end
end
describe 'explore_features' do
2025-08-13 14:25:48 -04:00
let(:mail) { UsersMailer.with(user: user).explore_features }
it 'renders the headers' do
expect(mail.subject).to eq('Explore Dawarich features!')
2025-09-18 12:29:46 -04:00
expect(mail.to).to eq([user.email])
2025-08-13 14:25:48 -04:00
end
end
describe 'trial_expires_soon' do
2025-08-13 14:25:48 -04:00
let(:mail) { UsersMailer.with(user: user).trial_expires_soon }
it 'renders the headers' do
expect(mail.subject).to eq('⚠️ Your Dawarich trial expires in 2 days')
2025-09-18 12:29:46 -04:00
expect(mail.to).to eq([user.email])
2025-08-13 14:25:48 -04:00
end
end
describe 'trial_expired' do
2025-08-13 14:25:48 -04:00
let(:mail) { UsersMailer.with(user: user).trial_expired }
it 'renders the headers' do
expect(mail.subject).to eq('💔 Your Dawarich trial expired')
2025-09-18 12:29:46 -04:00
expect(mail.to).to eq([user.email])
2025-08-13 14:25:48 -04:00
end
end
2025-09-13 09:58:36 -04:00
describe 'post_trial_reminder_early' do
let(:mail) { UsersMailer.with(user: user).post_trial_reminder_early }
it 'renders the headers' do
expect(mail.subject).to eq('🚀 Still interested in Dawarich? Subscribe now!')
2025-09-18 12:29:46 -04:00
expect(mail.to).to eq([user.email])
2025-09-13 09:58:36 -04:00
end
end
describe 'post_trial_reminder_late' do
let(:mail) { UsersMailer.with(user: user).post_trial_reminder_late }
it 'renders the headers' do
expect(mail.subject).to eq('📍 Your location data is waiting - Subscribe to Dawarich')
2025-09-18 12:29:46 -04:00
expect(mail.to).to eq([user.email])
2025-09-13 09:58:36 -04:00
end
end
2025-08-13 14:25:48 -04:00
end