2025-08-14 14:50:22 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2025-09-13 09:37:09 -04:00
|
|
|
require 'rails_helper'
|
2025-08-13 14:25:48 -04:00
|
|
|
|
|
|
|
|
RSpec.describe UsersMailer, type: :mailer do
|
|
|
|
|
let(:user) { create(:user, email: 'test@example.com') }
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
stub_const('ENV', ENV.to_hash.merge('SMTP_FROM' => 'hi@dawarich.app'))
|
|
|
|
|
end
|
|
|
|
|
|
2025-09-13 09:37:09 -04:00
|
|
|
describe 'welcome' do
|
2025-08-13 14:25:48 -04:00
|
|
|
let(:mail) { UsersMailer.with(user: user).welcome }
|
|
|
|
|
|
2025-09-13 09:37:09 -04:00
|
|
|
it 'renders the headers' do
|
|
|
|
|
expect(mail.subject).to eq('Welcome to Dawarich!')
|
|
|
|
|
expect(mail.to).to eq(['test@example.com'])
|
2025-08-13 14:25:48 -04:00
|
|
|
end
|
|
|
|
|
|
2025-09-13 09:37:09 -04:00
|
|
|
it 'renders the body' do
|
|
|
|
|
expect(mail.body.encoded).to match('test@example.com')
|
2025-08-13 14:25:48 -04:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-09-13 09:37:09 -04:00
|
|
|
describe 'explore_features' do
|
2025-08-13 14:25:48 -04:00
|
|
|
let(:mail) { UsersMailer.with(user: user).explore_features }
|
|
|
|
|
|
2025-09-13 09:37:09 -04:00
|
|
|
it 'renders the headers' do
|
|
|
|
|
expect(mail.subject).to eq('Explore Dawarich features!')
|
|
|
|
|
expect(mail.to).to eq(['test@example.com'])
|
2025-08-13 14:25:48 -04:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-09-13 09:37:09 -04:00
|
|
|
describe 'trial_expires_soon' do
|
2025-08-13 14:25:48 -04:00
|
|
|
let(:mail) { UsersMailer.with(user: user).trial_expires_soon }
|
|
|
|
|
|
2025-09-13 09:37:09 -04:00
|
|
|
it 'renders the headers' do
|
|
|
|
|
expect(mail.subject).to eq('⚠️ Your Dawarich trial expires in 2 days')
|
|
|
|
|
expect(mail.to).to eq(['test@example.com'])
|
2025-08-13 14:25:48 -04:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-09-13 09:37:09 -04:00
|
|
|
describe 'trial_expired' do
|
2025-08-13 14:25:48 -04:00
|
|
|
let(:mail) { UsersMailer.with(user: user).trial_expired }
|
|
|
|
|
|
2025-09-13 09:37:09 -04:00
|
|
|
it 'renders the headers' do
|
|
|
|
|
expect(mail.subject).to eq('💔 Your Dawarich trial expired')
|
|
|
|
|
expect(mail.to).to eq(['test@example.com'])
|
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!')
|
|
|
|
|
expect(mail.to).to eq(['test@example.com'])
|
|
|
|
|
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')
|
|
|
|
|
expect(mail.to).to eq(['test@example.com'])
|
|
|
|
|
end
|
|
|
|
|
end
|
2025-08-13 14:25:48 -04:00
|
|
|
end
|