Sha256: de4f0ad98a202024b78ab6bd37793737b71744d3bf93981175c1fcc247adadf1

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 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)

        image = product.images.build
        image.valid?
      end
            
      def test_should_not_save_product_without_image
        product = create_product
        assert_not product.save
      end

      def test_will_through_error_if_image_size_is_more_than_2GB
        product = create_product
        product.images.create(image: product_image_file)
        image = product.images.build
       
        image.valid?
        assert_not product.save
      end

      def test_will_through_error_if_image_format_is_other_than_jpeg
        product = create_product
        product.images.create(image: product_image_file)
        image = product.images.build

        image.valid?
        assert_not product.save
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-image_decoration-1.0.0.pre test/models/workarea/catalog/product_image_test.rb