require_relative '../../rails_helper' module Symphonia RSpec.describe Notifier do let(:user) { FactoryBot.create(:user) } before(:each) { I18n.locale = :cs } context '#test_mail' do let(:mail) { described_class.test_mail(user) } it 'renders the headers' do expect(mail.subject).to eq('Symphonia testing mail') expect(mail.to).to eq([user.email]) end it 'renders the body' do expect(mail.body.encoded).to match('Testing mail from Symphonia system') end end context '#activation_user' do let(:mail) { described_class.activation_user(user) } it 'renders the headers' do expect(mail.subject).to match 'Aktivace' expect(mail.to).to eq([user.email]) end it 'renders the body' do expect(mail.body.encoded).to match user.perishable_token end end context '#user_change_to_active' do let(:mail) { described_class.user_change_to_active(user) } it 'renders the headers' do expect(mail.subject).to match 'aktivován' expect(mail.to).to eq([user.email]) end it 'renders the body' do expect(mail.body.encoded).to match "users/#{user.id}" end end context '#reset_password_user' do let(:mail) { described_class.reset_password_user(user) } it 'renders the headers' do expect(mail.subject).to match 'heslo' expect(mail.to).to eq([user.email]) end it 'renders the body' do expect(mail.body.encoded).to match "reset_password/#{user.perishable_token}" end end context '#user_registered' do let(:notify) { FactoryBot.create(:email_preference, :user_registered) } let!(:admin) { FactoryBot.create(:user, { preferences: [notify]}) } let(:mail) { described_class.user_registered(user) } it 'renders the headers' do expect(mail.subject).to match 'nový uživatel' expect(mail.to).to eq([admin.email]) end it 'renders the body' do expect(mail.body.encoded).to match user.name end end end end