Skip to content

Commit 0828c67

Browse files
estolfopicandocodigo
authored andcommitted
Remove special handling for create and just use index endpoint
1 parent f0fa9dc commit 0828c67

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

elasticsearch-api/lib/elasticsearch/api/actions/create.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def create(arguments = {})
4848
end
4949
request_opts[:defined_params] = defined_params unless defined_params.empty?
5050

51-
arguments.update endpoint: 'create'
5251
if arguments[:id]
5352
index arguments.update op_type: 'create'
5453
else

elasticsearch-api/spec/elasticsearch/api/perform_request_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
let(:client_double) do
3939
Class.new { include Elasticsearch::API }.new.tap do |client|
4040
expect(client).to receive(:perform_request) do |_, _, _, _, _, request_params|
41+
# The create method ends up becoming an 'index' request
42+
if expected_perform_request_params[:endpoint] == 'create'
43+
expected_perform_request_params[:endpoint] = 'index'
44+
end
4145
# Check that the expected hash is passed to the perform_request method
4246
expect(request_params).to eq(expected_perform_request_params)
4347
end.and_return(response_double)

elasticsearch-api/utils/thor/templates/method.erb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ module Elasticsearch
3434
<%- end %>
3535
<%- %>
3636
<%- if @spec.endpoint_name == 'create' -%>
37-
<%= ' '*(@spec.namespace_depth+3) %>arguments.update endpoint: 'create'
3837
<%= ' '*(@spec.namespace_depth+3) %>if arguments[:id]
3938
<%= ' '*(@spec.namespace_depth+3) %> index arguments.update op_type: 'create'
4039
<%= ' '*(@spec.namespace_depth+3) %>else

0 commit comments

Comments
 (0)