Sha256: 74f53eec68031233f443761a526519bb74c46d563dde0c8450282550ccb9bb95

Contents?: true

Size: 1.4 KB

Versions: 57

Compression:

Stored size: 1.4 KB

Contents

require 'test_helper'

module Workarea
  module Catalog
    class ProductImageTest < TestCase
      def test_delegates_methods_to_its_asset
        product_image = Workarea::Catalog::ProductImage.new
        product_image.image = File.new(product_image_file_path)
        assert_equal(product_image.image.name, product_image.name)
      end

      def test_valid?
        product = create_product
        product.images.create(image: product_image_file, position: 0)

        image = product.images.build
        image.valid?

        assert_equal(1, image.position)
      end

      def test_always_order_by_position
        product = create_product
        product.images.create(image: product_image_file, position: 1)
        product.images.create(image: product_image_file, position: 0)
        product.reload

        assert_equal([0, 1], product.images.map(&:position))
      end

      def test_falling_back_to_recently_updated_sorting
        product = create_product
        one = product.images.create!(image: product_image_file, position: 0)
        two = product.images.create!(image: product_image_file, position: 0)
        assert_equal([two, one], product.reload.images)
      end

      def test_populate_fields
        product = create_product
        image = product.images.create!(image: product_image_file, position: 0)

        assert_equal(1.0, image.image_inverse_aspect_ratio)
      end
    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

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