Sha256: feca0d5dca7d566d4e61a988d118aa7abe3fd929bec4d07e034d8571aaf8d623

Contents?: true

Size: 1.31 KB

Versions: 28

Compression:

Stored size: 1.31 KB

Contents

require 'test_helper'

module Workarea
  module Admin
    class ProductRulesPreviewViewModelTest < TestCase
      def test_only_uses_active_rules
        customization = create_search_customization(
          id: 'foo',
          product_rules: [
            { name: 'excluded_products', operator: 'equals', value: '1' },
            { name: 'excluded_products', operator: 'equals', value: '2', active: false }
          ]
        )

        view_model = ProductRulesPreviewViewModel.wrap(customization)
        assert(view_model.display_results?)
        assert_equal(customization.product_rules.take(1), view_model.search.params[:rules])

        category = create_category(
          product_rules: [
            { name: 'excluded_products', operator: 'equals', value: '1' },
            { name: 'excluded_products', operator: 'equals', value: '2', active: false }
          ]
        )

        view_model = ProductRulesPreviewViewModel.wrap(category)
        assert(view_model.display_results?)
        assert_equal(category.product_rules.take(1), view_model.search.params[:rules])

        category.product_rules.first.update!(active: false)
        view_model = ProductRulesPreviewViewModel.wrap(category)
        refute(view_model.display_results?)
        assert_empty(view_model.search.params[:rules])
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-admin-3.5.27 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.26 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.25 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.23 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.22 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.21 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.20 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.19 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.18 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.17 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.16 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.15 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.14 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.13 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.12 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.11 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.10 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.9 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.8 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
workarea-admin-3.5.7 test/view_models/workarea/admin/product_rules_preview_view_model_test.rb