Sha256: 3690d2c306fa621dd8bc75e3c90576da9e38115bc88eb09a3c62bcd77e9e3b0d

Contents?: true

Size: 1.38 KB

Versions: 28

Compression:

Stored size: 1.38 KB

Contents

require 'test_helper'

module Workarea
  module Admin
    class StatusReportMailerTest < MailerTest
      include TestCase::SearchIndexing
      include TestCase::Mail

      delegate :t, to: :I18n

      def test_report
        # create a Products Missing Images alert
        create_product(images: [], description: nil)

        Workarea.config.email_from = 'noreply@example.com'
        user = create_user(email: 'bcrouse@workarea.com')

        StatusReportMailer.report(user.email).deliver_now

        email = ActionMailer::Base.deliveries.last
        html = email.parts.second.body

        assert_includes(html, Workarea.config.site_name)
        assert_includes(html, t('workarea.admin.status_report_mailer.orders.total_orders'))
        assert_includes(html, t('workarea.admin.status_report_mailer.alerts.title'))
        assert_includes(html, t('workarea.admin.status_report_mailer.unsubscribe'))
        assert_includes(html, Money.default_currency.symbol)
        assert_includes(email.to, user.email)
        assert_includes(email.from, Workarea.config.email_from)
      end

      def test_report_to_many
        users = [
          create_user(email: 'bcrouse@workarea.com'),
          create_user(email: 'tscott@workarea.com')
        ]

        StatusReportMailer.report_to_many(users).map(&:deliver_now)
        assert_equal(2, ActionMailer::Base.deliveries.count)
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-admin-3.5.6 test/mailers/workarea/admin/status_report_mailer_test.rb
workarea-admin-3.5.5 test/mailers/workarea/admin/status_report_mailer_test.rb
workarea-admin-3.5.4 test/mailers/workarea/admin/status_report_mailer_test.rb
workarea-admin-3.5.3 test/mailers/workarea/admin/status_report_mailer_test.rb
workarea-admin-3.5.2 test/mailers/workarea/admin/status_report_mailer_test.rb
workarea-admin-3.5.1 test/mailers/workarea/admin/status_report_mailer_test.rb
workarea-admin-3.5.0 test/mailers/workarea/admin/status_report_mailer_test.rb
workarea-admin-3.5.0.beta.1 test/mailers/workarea/admin/status_report_mailer_test.rb