diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/xapian_spec.rb | 15 | ||||
-rw-r--r-- | spec/spec_helper.rb | 10 |
2 files changed, 12 insertions, 13 deletions
diff --git a/spec/models/xapian_spec.rb b/spec/models/xapian_spec.rb index 51d410660..8e8616df5 100644 --- a/spec/models/xapian_spec.rb +++ b/spec/models/xapian_spec.rb @@ -14,7 +14,6 @@ describe User, " when indexing users with Xapian" do it "should search by 'about me' text" do user = users(:bob_smith_user) - rebuild_xapian_index # def InfoRequest.full_search(models, query, order, ascending, collapse, per_page, page) xapian_object = InfoRequest.full_search([User], "stuff", 'created_at', true, nil, 100, 1) xapian_object.results.size.should == 1 @@ -34,7 +33,7 @@ describe User, " when indexing users with Xapian" do end describe PublicBody, " when indexing public bodies with Xapian" do - fixtures :public_bodies, :public_body_translations, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments + fixtures :public_bodies, :public_body_translations, :incoming_messages, :outgoing_messages, :raw_emails, :comments, :info_requests before(:each) do load_raw_emails_data(raw_emails) end @@ -72,7 +71,7 @@ describe PublicBody, " when indexing public bodies with Xapian" do end describe PublicBody, " when indexing requests by body they are to" do - fixtures :public_bodies, :public_body_translations, :info_requests, :raw_emails, :comments, :info_request_events + fixtures :public_bodies, :public_body_translations, :info_request_events, :info_requests, :raw_emails, :comments before(:each) do load_raw_emails_data(raw_emails) @@ -132,7 +131,7 @@ describe PublicBody, " when indexing requests by body they are to" do end describe User, " when indexing requests by user they are from" do - fixtures :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events + fixtures :users, :info_request_events, :info_requests, :incoming_messages, :outgoing_messages, :raw_emails, :comments before(:each) do load_raw_emails_data(raw_emails) end @@ -219,7 +218,7 @@ describe User, " when indexing requests by user they are from" do end describe User, " when indexing comments by user they are by" do - fixtures :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events + fixtures :users, :info_request_events, :info_requests, :comments, :incoming_messages, :outgoing_messages, :raw_emails, :comments before(:each) do load_raw_emails_data(raw_emails) end @@ -256,7 +255,7 @@ describe User, " when indexing comments by user they are by" do end describe InfoRequest, " when indexing requests by their title" do - fixtures :info_requests, :raw_emails, :incoming_messages, :comments, :info_request_events + fixtures :info_request_events, :info_requests, :incoming_messages, :raw_emails, :comments before(:each) do load_raw_emails_data(raw_emails) end @@ -287,7 +286,7 @@ describe InfoRequest, " when indexing requests by their title" do end describe InfoRequest, " when indexing requests by tag" do - fixtures :info_requests, :raw_emails, :incoming_messages, :comments, :info_request_events + fixtures :info_request_events, :info_requests, :incoming_messages, :raw_emails, :comments before(:each) do load_raw_emails_data(raw_emails) end @@ -309,7 +308,7 @@ describe InfoRequest, " when indexing requests by tag" do end describe PublicBody, " when indexing authorities by tag" do - fixtures :public_bodies, :public_body_translations, :raw_emails, :incoming_messages, :outgoing_messages, :comments + fixtures :public_bodies, :public_body_translations, :incoming_messages, :outgoing_messages, :raw_emails, :comments before(:each) do load_raw_emails_data(raw_emails) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a486418ce..d1b3083c4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -81,11 +81,11 @@ def load_file_fixture(file_name) end def rebuild_xapian_index - # XXX could for speed call ActsAsXapian.rebuild_index directly, but would - # need model name list, and would need to fix acts_as_xapian so can call writes - # and reads mixed up (it asserts where it thinks it can't do this) - rebuild_name = File.dirname(__FILE__) + '/../script/rebuild-xapian-index' - Kernel.system(rebuild_name) or raise "failed to launch #{rebuild_name}, error bitcode #{$?}, exit status: #{$?.exitstatus}" + verbose = false + # safe_rebuild=true, which involves forking to avoid memory leaks, doesn't work well with rspec. + # unsafe is significantly faster, and we can afford possible memory leaks while testing. + safe_rebuild = false + ActsAsXapian.rebuild_index(["PublicBody", "User", "InfoRequestEvent"].map{|m| m.constantize}, verbose, safe_rebuild) end def update_xapian_index |