Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

Commit

Permalink
[FIX] Fix broken unit tests for facets
Browse files Browse the repository at this point in the history
  • Loading branch information
karmi committed Jan 4, 2013
1 parent 5a28781 commit 087d3c8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/tire/search/facet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def terms(field, options={})
end

def date(field, options={})
interval = options.delete(:interval) || 'day'
interval = { :interval => options.delete(:interval) || 'day' }
fields = options[:value_field] || options[:value_script] ? { :key_field => field } : { :field => field }
@value[:date_histogram] = { :interval => interval }.update(fields).update(options)
@value[:date_histogram] = {}.update(fields).update(interval).update(options)
self
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/search_facet_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def foo; 'bar'; end

should "encode custom options" do
f = Facet.new('date') { date :published_on, :value_field => 'price' }
assert_equal( {:date=>{:date_histogram=>{:field=>'published_on',:interval=>'day',:value_field=>'price' } } }.to_json,
assert_equal( {:date=>{:date_histogram=>{:key_field=>'published_on',:interval=>'day',:value_field=>'price' } } }.to_json,
f.to_json )
end

Expand Down

0 comments on commit 087d3c8

Please sign in to comment.