Method: Elastictastic::TestHelpers#stub_es_create

Defined in:
lib/elastictastic/test_helpers.rb

#stub_es_create(index, type, id = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/elastictastic/test_helpers.rb', line 11

def stub_es_create(index, type, id = nil)
  if id.nil?
    id = generate_es_id
    components = [index, type]
    method = :post
  else
    components = [index, type, id, '_create']
    method = :put
  end

  stub_request_json(
    method,
    match_es_resource(components),
    generate_es_hit(type, :id => id, :index => index).merge('ok' => 'true')
  )
  id
end