Sha256: 29b3ae98b9ad0b8f2eadbff4b243f4e79dee5ad396cf865da545be1ed80aa5ae

Contents?: true

Size: 1.83 KB

Versions: 62

Compression:

Stored size: 1.83 KB

Contents

require 'test_helper'

module Workarea
  module Admin
    class SearchSettingsIntegrationTest < Workarea::IntegrationTest
      include Admin::IntegrationTest

      def test_can_create_an_asset
        patch admin.search_settings_path,
          params: {
            synonyms: 'foo, bar',
            boosts: { 'name' => 3, 'description' => 0.5 },
            views_factor: 1.25,
            terms_facets_list: 'color, size',
            range_facets: {
              'price' => [
                { 'from' => '', 'to' => '9.99' },
                { 'from' => '10', 'to' => '19.99' }
              ]
            }
          }

        settings = Search::Settings.current

        assert_equal('foo, bar', settings.synonyms)
        assert_equal('3', settings.boosts['name'])
        assert_equal('0.5', settings.boosts['description'])
        assert_equal(1.25, settings.views_factor)
        assert_equal(%w(color size), settings.terms_facets)
        assert_equal(
          { 'price' => [{ 'to' => 9.99 }, { 'from' => 10.0, 'to' => 19.99 }] },
          settings.range_facets
        )
      end

      def test_retains_settings_when_partially_updated
        settings = Search::Settings.current
        terms_facets = %w[color size material]
        range_facets = {
          'price' => [
            { 'from' => '', 'to' => '9.99' },
            { 'from' => '10', 'to' => '' }
          ]
        }

        settings.update!(
          terms_facets: terms_facets,
          range_facets: range_facets
        )
        patch admin.search_settings_path,
          params: {
            settings: {
              synonyms: 'foo, bar, baz'
            }
          }

        assert_equal('foo, bar, baz', settings.reload.synonyms)
        assert_equal(terms_facets, settings.terms_facets)
        assert_equal(range_facets, settings.range_facets)
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

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