Sha256: 60e71a62b353bb63e33a98766d472be1d854baeab237002c5c4399b1ed2adbd6

Contents?: true

Size: 1.53 KB

Versions: 50

Compression:

Stored size: 1.53 KB

Contents

require 'test_helper'

module Elasticsearch
  module Test
    class IndexDocumentTest < ::Test::Unit::TestCase

      context "Creating a document with the #create method" do
        subject { FakeClient.new }

        should "perform the create request" do
          subject.expects(:perform_request).with do |method, url, params, body|
            assert_equal 'POST', method
            assert_equal 'foo/bar', url
            assert_equal({:op_type => 'create'}, params)
            assert_equal({:foo => 'bar'}, body)
            true
          end.returns(FakeResponse.new)

          subject.create :index => 'foo', :type => 'bar', :body => {:foo => 'bar'}
        end

        should "perform the create request with a specific ID" do
          subject.expects(:perform_request).with do |method, url, params, body|
            assert_equal 'PUT', method
            assert_equal 'foo/bar/123', url
            assert_equal 'create', params[:op_type]
            assert_nil   params[:id]
            assert_equal({:foo => 'bar'}, body)
            true
          end.returns(FakeResponse.new)

          subject.create :index => 'foo', :type => 'bar', :id => '123', :body => {:foo => 'bar'}
        end

        should "URL-escape the parts" do
          subject.expects(:perform_request).with do |method, url, params, body|
            assert_equal 'foo/bar%2Fbam/123', url
            true
          end.returns(FakeResponse.new)

          subject.create :index => 'foo', :type => 'bar/bam', :id => '123', :body => {}
        end
      end

    end
  end
end

Version data entries

50 entries across 50 versions & 2 rubygems

Version Path
elasticsearch-api-1.1.3 test/unit/create_document_test.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/elasticsearch-api-5.0.4/test/unit/create_document_test.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/elasticsearch-api-5.0.4/test/unit/create_document_test.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/elasticsearch-api-5.0.4/test/unit/create_document_test.rb
elasticsearch-api-5.0.4 test/unit/create_document_test.rb
elasticsearch-api-2.0.2 test/unit/create_document_test.rb
elasticsearch-api-5.0.3 test/unit/create_document_test.rb
elasticsearch-api-5.0.2 test/unit/create_document_test.rb
elasticsearch-api-5.0.1 test/unit/create_document_test.rb
elasticsearch-api-2.0.1 test/unit/create_document_test.rb
elasticsearch-api-1.1.2 test/unit/create_document_test.rb
elasticsearch-api-1.1.1 test/unit/create_document_test.rb
elasticsearch-api-5.0.0 test/unit/create_document_test.rb
elasticsearch-api-5.0.0.pre test/unit/create_document_test.rb
elasticsearch-api-2.0.0 test/unit/create_document_test.rb
elasticsearch-api-1.1.0 test/unit/create_document_test.rb
elasticsearch-api-2.0.0.pre test/unit/create_document_test.rb
elasticsearch-api-1.1.pre test/unit/create_document_test.rb
elasticsearch-api-1.0.18 test/unit/create_document_test.rb
elasticsearch-api-1.0.17 test/unit/create_document_test.rb