From b8b100f2b3eef9a49d0dc22ee40594bdf1adb777 Mon Sep 17 00:00:00 2001 From: Alan Heywood Date: Mon, 25 Nov 2013 18:09:44 +1100 Subject: [PATCH] Pass the :refresh param through Index#store Add support for http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-index_.html#index-refresh --- lib/tire/index.rb | 1 + test/unit/index_test.rb | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/tire/index.rb b/lib/tire/index.rb index a3ac3a51..22aa38b4 100644 --- a/lib/tire/index.rb +++ b/lib/tire/index.rb @@ -138,6 +138,7 @@ def store(*args) params[:routing] = options[:routing] if options[:routing] params[:replication] = options[:replication] if options[:replication] params[:version] = options[:version] if options[:version] + params[:refresh] = options[:refresh] if options[:refresh] params_encoded = params.empty? ? '' : "?#{params.to_param}" diff --git a/test/unit/index_test.rb b/test/unit/index_test.rb index 6440c97d..cc50f60d 100644 --- a/test/unit/index_test.rb +++ b/test/unit/index_test.rb @@ -335,6 +335,16 @@ class MyDocument;end; document = MyDocument.new @index.store({:title => 'Test'}, {:replication => 'async'}) end + should "extract the refresh type from options" do + Configuration.client.expects(:post). + with do |url, payload| + assert_equal "#{Configuration.url}/dummy/document/?refresh=true", url + end. + returns(mock_response('{"ok":true,"_id":"test"}')) + + @index.store({:title => 'Test'}, {:refresh => 'true'}) + end + should "extract the version from options" do Configuration.client.expects(:post). with do |url, payload|