Skip to content

Commit

Permalink
[DSL] Changed, that global aggregation takes a block
Browse files Browse the repository at this point in the history
Changed global aggregation to behave like a nested aggregation

Related: #213

Closes #228
  • Loading branch information
Kristopher Bredemeier authored and karmi committed Dec 21, 2015
1 parent 9d32db1 commit 1ea2d68
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/elasticsearch/dsl/search/aggregations/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Aggregations
# @see http://elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html
#
class Global
include BaseComponent
include BaseAggregationComponent
end

end
Expand Down
20 changes: 19 additions & 1 deletion test/unit/aggregations/global_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,25 @@ class GlobalTest < ::Test::Unit::TestCase
should "be converted to a Hash" do
assert_equal({ global: {} }, subject.to_hash)
end


should "take a block" do
subject = Global.new do
end
assert_equal({global: {} }, subject.to_hash)
end

should "define aggregations" do
subject = Global.new do
aggregation :foo do
terms field: "bar"
end
end
expected = {
aggregations: { foo: { terms: { field: "bar" } } },
global: {}
}
assert_equal(expected, subject.to_hash)
end
end
end
end
Expand Down

0 comments on commit 1ea2d68

Please sign in to comment.