Created
February 11, 2010 11:28
-
-
Save keithpitty/301434 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# order.rb | |
# == Schema Information | |
# | |
# Table name: orders | |
# | |
# id :integer(11) not null, primary key | |
# date_ordered :date | |
class Order < ActiveRecord::Base | |
define_index do | |
indexes date_ordered | |
end | |
end | |
# search_test.rb | |
require File.dirname(__FILE__) + '/../test_helper' | |
class SearchTest < ActiveRecord::TestCase | |
# assume expected_order has been created with date_ordered == '2009-02-11' | |
def test_should_find_order_based_on_date | |
# This works. | |
orders = Order.search "2009-02-11" | |
assert_equal expected_order, orders.first | |
end | |
def test_should_find_order_based_on_explicit_date | |
# This fails because it returns all orders not just those with date_ordered == '2009-02-11'. | |
# Why, I do not know. | |
orders = Order.search :conditions => {:date_ordered => Date.parse('2009-02-11')} | |
assert_equal expected_order, orders.first | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment