2019-10-14 08:54:58 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-10-20 08:47:26 +00:00
|
|
|
require 'rails_helper'
|
2019-10-14 08:54:58 +00:00
|
|
|
|
|
|
|
RSpec.describe 'Confirmation Instructions', type: :mailer do
|
|
|
|
describe :notify do
|
|
|
|
let(:confirmable_user) { FactoryBot.build(:user, inviter: inviter_val) }
|
|
|
|
let(:inviter_val) { nil }
|
|
|
|
let(:mail) { confirmable_user.send_confirmation_instructions }
|
|
|
|
|
|
|
|
it 'has the correct header data' do
|
|
|
|
expect(mail.reply_to).to contain_exactly('accounts@chatwoot.com')
|
|
|
|
expect(mail.to).to contain_exactly(confirmable_user.email)
|
|
|
|
expect(mail.subject).to eq('Confirmation Instructions')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'uses the user\'s name' do
|
2019-12-03 17:24:08 +00:00
|
|
|
expect(mail.body).to match("Welcome, #{CGI.escapeHTML(confirmable_user.name)}!")
|
2019-10-14 08:54:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not refer to the inviter and their account' do
|
|
|
|
expect(mail.body).to_not match('has invited you to try out Chatwoot!')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there is an inviter' do
|
|
|
|
let(:inviter_val) do
|
|
|
|
FactoryBot.create(:user, role: :administrator, skip_confirmation: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'refers to the inviter and their account' do
|
|
|
|
expect(mail.body).to match(
|
|
|
|
"#{inviter_val.name}, with #{inviter_val.account.name}, has invited you to try out Chatwoot!"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|