Sha256: 7b91235a6f0850b5c20f5fc0d19ff4548841816137c844ec5a1490364358156f

Contents?: true

Size: 1.41 KB

Versions: 34

Compression:

Stored size: 1.41 KB

Contents

require 'test_helper'

module Workarea
  module Storefront
    class ContentHelperTest < ViewTest
      include Workarea::ApplicationHelper

      def test_render_content_blocks
        content = create_content
        content.blocks.create!(type: :html)
        blocks = ContentBlockViewModel.wrap(content.blocks)

        self.expects(:current_user).returns(nil)
        Rails.cache.expects(:fetch).once
        render_content_blocks(blocks)

        self.expects(:current_user).returns(create_user(admin: true))
        Rails.cache.expects(:fetch).never
        render_content_blocks(blocks)
      end

      def test_intrinsic_ratio_frame_styles
        asset = create_asset(file: product_image_file)
        result = intrinsic_ratio_frame_styles(asset)
        assert_equal('padding: 0 0 100.0%; height: 0;', result)

        asset = create_asset(
          file: product_image_file,
          file_inverse_aspect_ratio: nil
        )

        result = intrinsic_ratio_frame_styles(asset)
        assert(result.blank?)
      end

      def test_content_block_classes
        content = create_content
        content.blocks.create!(
          type: :image_group,
          data: {
            hidden_breakpoints: []
          }
        )
        blocks = ContentBlockViewModel.wrap(content.blocks)

        assert_equal(['content-block', "content-block--image-group"], content_block_classes_for(blocks.first))
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-storefront-3.4.45 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.44 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.43 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.42 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.41 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.40 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.39 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.38 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.37 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.36 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.35 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.34 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.33 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.32 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.31 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.30 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.29 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.28 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.27 test/helpers/workarea/storefront/content_helper_test.rb
workarea-storefront-3.4.26 test/helpers/workarea/storefront/content_helper_test.rb