Sha256: 57591f935f1a92e67b6a564362d3071ef98f377a110f9693fe0f2786989d06d2

Contents?: true

Size: 912 Bytes

Versions: 6

Compression:

Stored size: 912 Bytes

Contents

require 'test_helper'

module Workarea
  class SendReviewRequestsTest < TestCase
    include TestCase::Mail

    def test_perform
      product = create_product(name: 'Foobar Product')

      requests = Array.new(3) { create_review_request(product_id: product.id) }
      create_review_request(product_id: product.id, send_after: 1.week.from_now)
      create_review_request(product_id: product.id, send_after: Time.current, canceled_at: Time.current)

      SendReviewRequests.new.perform

      requests.each(&:reload)
      assert(requests.all?(&:sent?))

      assert_equal(3, ActionMailer::Base.deliveries.size)

      email = ActionMailer::Base.deliveries.last
      assert_includes(email.to, 'test@workarea.com')
      assert_includes(email.subject, product.name)
      assert_includes(
        email.parts.second.body,
        t('workarea.storefront.email.review_request.link')
      )
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
workarea-reviews-3.1.2 test/workers/workarea/send_review_requests_test.rb
workarea-reviews-3.1.1 test/workers/workarea/send_review_requests_test.rb
workarea-reviews-3.1.0 test/workers/workarea/send_review_requests_test.rb
workarea-reviews-3.0.10 test/workers/workarea/send_review_requests_test.rb
workarea-reviews-3.0.9 test/workers/workarea/send_review_requests_test.rb
workarea-reviews-3.0.8 test/workers/workarea/send_review_requests_test.rb