Sha256: 6bbcb8eeccf86a0f36983343c13ca5315028488b9cbf123e543aba198171ee9d

Contents?: true

Size: 1.66 KB

Versions: 62

Compression:

Stored size: 1.66 KB

Contents

require 'test_helper'

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

      def test_autocomplete
        create_search_customization(id: 'test', query: 'test')
        create_search_customization(id: 'test_foo', query: 'test foo')

        get admin.search_customizations_path(format: 'json', q: 'tes'), xhr: true

        results = JSON.parse(response.body)['results']
        assert_equal(2, results.length)
      end

      def test_creating
        post admin.search_customizations_path, params: { q: 'Test' }

        assert_equal(1, Search::Customization.count)
        customization = Search::Customization.first

        assert_equal('test', customization.id)
        assert_equal('test', customization.query)
      end

      def test_invalid_creation
        assert_nothing_raised do
          post admin.search_customizations_path, params: { q: '' }
        end

        assert_redirected_to(admin.root_path)
      end

      def test_updating
        customization = create_search_customization

        patch admin.search_customization_path(customization),
          params: {
            customization: {
              rewrite: 'bar',
              redirect: 'http://www.foo.com'
            }
          }

        customization.reload

        assert_equal('bar', customization.rewrite)
        assert_equal('http://www.foo.com', customization.redirect)
      end

      def test_deleting
        customization = create_search_customization
        delete admin.search_customization_path(customization)
        assert_equal(0, Search::Customization.count)
      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_customizations_integration_test.rb
workarea-admin-3.5.26 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.4.45 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.5.25 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.5.23 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.4.44 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.5.22 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.4.43 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.5.21 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.4.42 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.5.20 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.4.41 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.5.19 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.4.40 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.5.18 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.4.39 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.5.17 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.4.38 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.5.16 test/integration/workarea/admin/search_customizations_integration_test.rb
workarea-admin-3.4.37 test/integration/workarea/admin/search_customizations_integration_test.rb