Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 44 lines (30 sloc) 1.324 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
require 'test_helper'

module Tire

  class IndexMappingIntegrationTest < Test::Unit::TestCase
    include Test::Integration

    context "Default mapping" do
      teardown { Tire.index('mapped-index').delete; sleep 0.1 }

      should "create and return the default mapping" do

        index = Tire.index 'mapped-index' do
          create
          store :type => :article, :title => 'One'
          refresh
          sleep 1
        end

        assert_equal 'string', index.mapping['article']['properties']['title']['type'], index.mapping.inspect
        assert_nil index.mapping['article']['properties']['title']['boost'], index.mapping.inspect
      end
    end

    context "Creating index with mapping" do
      teardown { Tire.index('mapped-index').delete; sleep 0.1 }
    
      should "create the specified mapping" do
    
        index = Tire.index 'mapped-index' do
          create :mappings => { :article => { :properties => { :title => { :type => 'string', :boost => 2.0, :store => 'yes' } } } }
        end

        # p index.mapping
        assert_equal 2.0, index.mapping['article']['properties']['title']['boost'], index.mapping.inspect
        assert_equal 'yes', index.mapping['article']['properties']['title']['store'], index.mapping.inspect
    
      end
    end

  end

end
Something went wrong with that request. Please try again.