Skip to content

Commit

Permalink
+ integration and regression test for the problem described by Jason …
Browse files Browse the repository at this point in the history
…Botwick
  • Loading branch information
floere committed Mar 4, 2011
1 parent 5d1cb4e commit 934cb4d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server/spec/lib/sources/db_spec.rb
Expand Up @@ -30,7 +30,7 @@

@connection.should_receive(:execute).
once.
with('SELECT indexed_id, some_category FROM some_type_type_index st WHERE st.id > some_offset LIMIT 25000').
with('SELECT id, some_category FROM some_type_type_index st WHERE st.__picky_id > some_offset LIMIT 25000').
and_return []

@source.get_data @type, @category, :some_offset
Expand All @@ -40,7 +40,7 @@
it 'yields to the caller' do
@connection.should_receive(:execute).
any_number_of_times.
with('SELECT indexed_id, some_category FROM some_type_type_index st WHERE st.id > some_offset LIMIT 25000').
with('SELECT id, some_category FROM some_type_type_index st WHERE st.__picky_id > some_offset LIMIT 25000').
and_return [[1, 'text']]

@source.get_data @type, @category, :some_offset do |id, text|
Expand Down Expand Up @@ -86,7 +86,7 @@
end
it "should get the id count" do
result = stub(:result, :to_i => 12_345)
@connection.should_receive(:select_value).once.with("SELECT COUNT(id) FROM some_type_name_type_index")
@connection.should_receive(:select_value).once.with("SELECT COUNT(__picky_id) FROM some_type_name_type_index")

@source.count @type
end
Expand Down Expand Up @@ -120,11 +120,11 @@
end
it "should add an AND if it already contains a WHERE statement" do
@source.should_receive(:harvest_statement).and_return 'WHERE'
@source.harvest_statement_with_offset(@type, @category, :some_offset).should == "WHERE AND st.id > some_offset LIMIT 25000"
@source.harvest_statement_with_offset(@type, @category, :some_offset).should == "WHERE AND st.__picky_id > some_offset LIMIT 25000"
end
it "should add a WHERE if it doesn't already contain one" do
@source.should_receive(:harvest_statement).and_return 'some_statement'
@source.harvest_statement_with_offset(@type, @category, :some_offset).should == "some_statement WHERE st.id > some_offset LIMIT 25000"
@source.harvest_statement_with_offset(@type, @category, :some_offset).should == "some_statement WHERE st.__picky_id > some_offset LIMIT 25000"
end
end

Expand Down
7 changes: 7 additions & 0 deletions server/test_project/spec/integration_spec.rb
Expand Up @@ -11,6 +11,7 @@
before(:all) do
Indexes.index_for_tests
Indexes.load_from_cache
@main = Query::Full.new Indexes[:main]
@sym = Query::Full.new Indexes[:symbol_keys]
@csv = Query::Full.new Indexes[:csv_test]
@memory_geo = Query::Full.new Indexes[:memory_geo]
Expand Down Expand Up @@ -51,6 +52,12 @@ def ids_of results
@csv.search_with_text('Soledad Human').ids.should == [72]
end

# Breakage.
#
it 'finds with id' do
@main.search_with_text('2').ids.should == [2]
end

# Standard.
#
it_should_find_ids_in_csv 'Soledad Human', [72]
Expand Down

0 comments on commit 934cb4d

Please sign in to comment.