diff options
author | Francis Irving <francis@mysociety.org> | 2010-06-16 17:17:03 +0100 |
---|---|---|
committer | Francis Irving <francis@mysociety.org> | 2010-06-16 17:17:03 +0100 |
commit | c22078e61089b230c3f32a278d9a70560cbb6d9a (patch) | |
tree | 7b8c97a793fb637b67a885af87aac978b56405e3 | |
parent | 09353425978a383477dd8171c08480162d24ced0 (diff) |
Test of body URL names longer than 64 characters, that they still index
-rw-r--r-- | spec/models/xapian_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/models/xapian_spec.rb b/spec/models/xapian_spec.rb index 5ee07bfb9..9c5f2121b 100644 --- a/spec/models/xapian_spec.rb +++ b/spec/models/xapian_spec.rb @@ -65,6 +65,28 @@ describe PublicBody, " when indexing requests by body they are to" do models_found_before.should == models_found_after end + + # if you index via the Xapian TermGenerator, it ignores terms of this length, + # this checks we're using Document:::add_term() instead + it "should work with URL names that are longer than 64 characters" do + rebuild_xapian_index + + # change the URL name of the body + body = public_bodies(:geraldine_public_body) + body.short_name = 'The Uncensored, Complete Name of the Quasi-Autonomous Public Body Also Known As Geraldine' + body.save! + body.url_name.size.should > 70 + update_xapian_index + + # check we get results expected + xapian_object = InfoRequest.full_search([InfoRequestEvent], "requested_from:tgq", 'created_at', true, nil, 100, 1) + xapian_object.results.size.should == 0 + xapian_object = InfoRequest.full_search([InfoRequestEvent], "requested_from:gq", 'created_at', true, nil, 100, 1) + xapian_object.results.size.should == 0 + xapian_object = InfoRequest.full_search([InfoRequestEvent], "requested_from:" + body.url_name, 'created_at', true, nil, 100, 1) + xapian_object.results.size.should == 4 + models_found_after = xapian_object.results.map { |x| x[:model] } + end end describe User, " when indexing requests by user they are from" do |