Skip to content

Commit e14c3c5

Browse files
committed
[MODEL] Fixed incorrect as_json serialization for Response::Result
1 parent 4d24ecd commit e14c3c5

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

elasticsearch-model/lib/elasticsearch/model/response/result.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def respond_to?(method_name, include_private = false)
3838
super
3939
end
4040

41+
def as_json(options={})
42+
@result.as_json(options)
43+
end
44+
4145
# TODO: #to_s, #inspect, with support for Pry
4246

4347
end

elasticsearch-model/test/unit/response_result_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,13 @@ class Elasticsearch::Model::ResultTest < Test::Unit::TestCase
4040
assert_raise(NoMethodError) { result.does_not_exist }
4141
end
4242

43+
should "delegate as_json to @result even when ActiveSupport changed half of Ruby" do
44+
require 'active_support/json/encoding'
45+
result = Elasticsearch::Model::Response::Result.new foo: 'bar'
46+
47+
result.instance_variable_get(:@result).expects(:as_json)
48+
result.as_json(except: 'foo')
49+
end
50+
4351
end
4452
end

0 commit comments

Comments
 (0)