Sha256: 8ab8d658afc6cb1e9212c68d79b7d171f0b1a34fb614360430b6cbc5790f4c8a

Contents?: true

Size: 1.3 KB

Versions: 35

Compression:

Stored size: 1.3 KB

Contents

require 'test_helper'

module Workarea
  module Storefront
    class SearchSuggestionViewModelTest < TestCase
      setup :set_asset_host_config
      teardown :restore_asset_host_config

      def set_asset_host_config
        @current_asset_host = Rails.application.config.action_controller.asset_host
        Rails.application.config.action_controller.asset_host = 'http://cdn.client.com'
      end

      def restore_asset_host_config
        Rails.application.config.action_controller.asset_host = @current_asset_host
      end

      def test_image_handles_blank
        search_suggestion = { '_source' => { 'cache' => { 'image' => '' } } }
        view_model = SearchSuggestionViewModel.new(search_suggestion)
        assert(view_model.image.nil?)
      end

      def test_image_handles_different_urls_from_index
        possible_index_urls = %w(
          /image.jpg
          https://staging.client.com/image.jpg
          http://cdn.client.com/image.jpg
        )

        possible_index_urls.each do |url_from_index|
          search_suggestion = {
            '_source' => { 'cache' => { 'image' => url_from_index } }
          }

          view_model = SearchSuggestionViewModel.new(search_suggestion)
          assert_equal('http://cdn.client.com/image.jpg', view_model.image)
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

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