Sha256: 51b833cde2a083a525f9d2b2b9d953901f721f8a6af5dd1c0fc2d86c885afaaa

Contents?: true

Size: 1.74 KB

Versions: 62

Compression:

Stored size: 1.74 KB

Contents

require 'test_helper'

module Workarea
  module Admin
    class ProductImagesIntegrationTest < Workarea::IntegrationTest
      include Admin::IntegrationTest
      setup :set_product

      def set_product
        @product = create_product
      end

      def test_creates_an_image
        post admin.catalog_product_images_path(@product),
          params: { image: { image: product_image_file, option: 'blue' } }

        @product.reload
        assert_equal(1, @product.images.length)
        assert_equal('blue', @product.images.first.option)
      end

      def test_updates_image_ordering
        image1 = @product.images.create!(
          image: product_image_file,
          option: 'blue'
        )

        image2 = @product.images.create!(
          image: product_image_file,
          option: 'blue'
        )

        post admin.positions_catalog_product_images_path(@product),
          params: { order: [image2.id, image1.id] }

        image1.reload
        assert_equal(1, image1.position)

        image2.reload
        assert_equal(0, image2.position)
      end

      def test_returns_a_list_of_matching_image_option_values
        @product.images.create!(
          image: product_image_file,
          option: 'blue'
        )

        get admin.options_catalog_product_images_path(@product, format: 'json', q: 'bl')

        results = JSON.parse(response.body)
        assert_equal([{ 'label' => 'Blue', 'value' => 'Blue' }], results['results'])
      end

      def test_destroys_an_image
        image = @product.images.create!(
          image: product_image_file,
          option: 'blue'
        )

        delete admin.catalog_product_image_url(@product, image)

        @product.reload
        assert_empty(@product.images)
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-admin-3.5.15 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.4.36 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.5.14 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.4.35 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.5.13 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.4.34 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.5.12 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.4.33 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.5.11 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.5.10 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.4.32 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.5.9 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.4.31 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.5.8 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.4.30 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.5.7 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.4.29 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.5.6 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.4.28 test/integration/workarea/admin/product_images_integration_test.rb
workarea-admin-3.5.5 test/integration/workarea/admin/product_images_integration_test.rb