Sha256: 62257fd39e36d4734b6eeef42666fe0e122a102b50d421fc6739e8039c3a69f5

Contents?: true

Size: 1.21 KB

Versions: 62

Compression:

Stored size: 1.21 KB

Contents

require 'test_helper'

module Workarea
  class OrderReminderTest < IntegrationTest
    setup do
      @product = create_product
    end

    def test_sending_an_email_for_every_order
      pass && (return) unless Workarea.config.send_transactional_emails

      101.times do |i|
        Order.create!(
          email: "mdalton-#{i}@workarea.com",
          checkout_started_at: Time.current - 2.hours,
          items: [{ product_id: @product.id, sku: @product.skus.first }]
        )
      end

      OrderReminder.new.perform
      assert_equal(ActionMailer::Base.deliveries.length, 101)
    end

    def test_setting_reminded_on_orders
      order_one = Order.create!(
        email: "mdalton-1@workarea.com",
        checkout_started_at: Time.current - 2.hours,
        items: [{ product_id: @product.id, sku: @product.skus.first }]
      )
      order_two = Order.create!(
        email: "mdalton-2@workarea.com",
        checkout_started_at: Time.current - 2.hours,
        items: [{ product_id: @product.id, sku: @product.skus.first }]
      )

      OrderReminder.new.perform

      order_one.reload
      assert(order_one.reminded_at.present?)

      order_two.reload
      assert(order_two.reminded_at.present?)
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/workers/workarea/order_reminder_test.rb
workarea-core-3.5.26 test/workers/workarea/order_reminder_test.rb
workarea-core-3.4.45 test/workers/workarea/order_reminder_test.rb
workarea-core-3.5.25 test/workers/workarea/order_reminder_test.rb
workarea-core-3.5.23 test/workers/workarea/order_reminder_test.rb
workarea-core-3.4.44 test/workers/workarea/order_reminder_test.rb
workarea-core-3.5.22 test/workers/workarea/order_reminder_test.rb
workarea-core-3.4.43 test/workers/workarea/order_reminder_test.rb
workarea-core-3.5.21 test/workers/workarea/order_reminder_test.rb
workarea-core-3.4.42 test/workers/workarea/order_reminder_test.rb
workarea-core-3.5.20 test/workers/workarea/order_reminder_test.rb
workarea-core-3.4.41 test/workers/workarea/order_reminder_test.rb
workarea-core-3.5.19 test/workers/workarea/order_reminder_test.rb
workarea-core-3.4.40 test/workers/workarea/order_reminder_test.rb
workarea-core-3.5.18 test/workers/workarea/order_reminder_test.rb
workarea-core-3.4.39 test/workers/workarea/order_reminder_test.rb
workarea-core-3.5.17 test/workers/workarea/order_reminder_test.rb
workarea-core-3.4.38 test/workers/workarea/order_reminder_test.rb
workarea-core-3.5.16 test/workers/workarea/order_reminder_test.rb
workarea-core-3.4.37 test/workers/workarea/order_reminder_test.rb