Sha256: 6b9f409230ba836106d22729defa03686822846a4bfa03a3d4a4c3f98d2eeb3f

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'test_helper'

module Workarea
  module Storefront
    class DownloadsIntegrationTest < Workarea::IntegrationTest
      def test_show
        token = create_fulfillment_token(sku: 'SKU1')
        sku = create_fulfillment_sku(id: 'SKU1', policy: :download, file: product_image_file)

        get storefront.download_path(token)
        assert(response.ok?)
        assert_equal(1, token.reload.downloads)

        token.update!(enabled: false)

        get storefront.download_path(token)
        assert_redirected_to(storefront.root_path)
        assert(flash[:info].present?)
        assert_equal(1, token.reload.downloads)

        token.update!(enabled: true)
        sku.update!(policy: 'ignore')

        get storefront.download_path(token)
        assert_redirected_to(storefront.root_path)
        assert(flash[:info].present?)
        assert_equal(1, token.reload.downloads)

        sku.destroy!

        get storefront.download_path(token)
        assert_redirected_to(storefront.root_path)
        assert(flash[:info].present?)
        assert_equal(1, token.reload.downloads)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-storefront-3.5.0.beta.1 test/integration/workarea/storefront/downloads_integration_test.rb