Sha256: 0833001f09e8dc2d0c6632992ba17c0d7c3a4df1a55893fd5656e0c5c58adbba

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

module NotifyUser
  describe NotificationMailer do
    describe 'notification_email' do
      let(:user) { build(:user) }
      let(:notification) { NewPostNotification.new(target: user) }
      let(:mailer) { NotificationMailer.send(:new, 'notification_email', notification, ActionMailerChannel.default_options) }
      let(:mail) { mailer.notification_email(notification, ActionMailerChannel.default_options) }

      before :each do
        allow(BaseNotification).to receive(:find).and_return(notification)
      end

      it 'renders the headers' do
        expect(mail.subject).to eq(ActionMailerChannel.default_options[:subject])
        expect(mail.to).to eq([user.email])
        expect(mail.from).to eq([NotifyUser.mailer_sender])
      end

      it "renders a template to render the notification's template as a partial" do
        mailer_should_render_template(mailer, 'notify_user/action_mailer/notification')
        mail
      end

      it 'renders with a layout' do
        allow_any_instance_of(NotificationMailer).to receive(:notification).and_return(notification)
        expect(mail.body.raw_source).to include 'This is the default generated layout'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
notify_user-0.3.2 spec/mailers/notify_user/notification_mailer_spec.rb
notify_user-0.3.1 spec/mailers/notify_user/notification_mailer_spec.rb