Sha256: f70eacf189c0cd1f041af5d0f0e3bcdfc97532dec5d69632acd9b0646367d917

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

require 'test_helper'

module Workarea
  module Storefront
    class SharingIntegrationTest < Workarea::IntegrationTest
      def test_sends_a_sharing_email
        from_email = 'bcrouse@workarea.com'
        to_email = 'bcrouse-friend@workarea.com'

        product = create_product(
          name: 'Integration Product',
          variants: [{ sku: 'SKU1', regular: 10.to_m }]
        )

        post storefront.shares_path(product),
             params: {
               url: storefront.product_url(product, host: Workarea.config.host),
               title: product.name,
               to_email: to_email,
               from_email: from_email,
               message: 'test message'
             }

        assert_redirected_to(storefront.product_path(product))

        email = ActionMailer::Base.deliveries.last

        email.parts.each do |part|
          assert_includes(part.body, product.name)
          assert_includes(part.body, 'test message')
          assert_includes(part.body, storefront.product_url(product))
        end

        assert_includes(email.to, to_email)
        assert_includes(email.from, Workarea.config.email_from)
        assert_includes(email.reply_to, from_email)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-share-1.3.0 test/integration/workarea/storefront/sharing_integration_test.rb
workarea-share-1.2.4 test/integration/workarea/storefront/sharing_integration_test.rb