Sha256: 4d210dfcec19a4e05b7331f769a667d5ab2abdb9f799fdbe06a14df66d6e5ad5

Contents?: true

Size: 904 Bytes

Versions: 8

Compression:

Stored size: 904 Bytes

Contents

# frozen_string_literal: true

module Spree
  class MailerPreviews
    class OrderPreview < ActionMailer::Preview
      def confirm
        order = Order.complete.last
        raise "Your database needs at least one completed order to render this preview" unless order
        OrderMailer.confirm_email(order)
      end

      def cancel
        order = Order.with_state(:canceled).last
        raise "Your database needs at least one cancelled order to render this preview" unless order
        OrderMailer.cancel_email(order)
      end

      def inventory_cancellation
        order = Spree::Order.joins(:inventory_units).merge(Spree::InventoryUnit.canceled).last
        raise "Your database needs at least one order with a canceled inventory unit to render this preview" unless order
        OrderMailer.inventory_cancellation_email(order, [order.inventory_units.first])
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
solidus_core-2.6.6 lib/spree/mailer_previews/order_preview.rb
solidus_core-2.6.5 lib/spree/mailer_previews/order_preview.rb
solidus_core-2.6.4 lib/spree/mailer_previews/order_preview.rb
solidus_core-2.6.3 lib/spree/mailer_previews/order_preview.rb
solidus_core-2.6.2 lib/spree/mailer_previews/order_preview.rb
solidus_core-2.6.1 lib/spree/mailer_previews/order_preview.rb
solidus_core-2.6.0 lib/spree/mailer_previews/order_preview.rb
solidus_core-2.6.0.rc1 lib/spree/mailer_previews/order_preview.rb