diff options
author | Mark Longair <mhl@pobox.com> | 2013-10-07 12:31:51 +0100 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2013-10-07 12:31:51 +0100 |
commit | 4d648e3e39c9ff0d721f1bf06266893a39c9b118 (patch) | |
tree | a6df3731c8ecdee2f3f4c7e467ca51d2094dc003 /spec/models | |
parent | 86f1fde1c2ace3e67185368033b3328ad8be83c2 (diff) |
Factor out a 'with_duplicate_xapian_job_creation' helper
In a subsequent commit, we will want to wrap an additional section
of code with the addition and removal of a hook that creates a
duplicate xapian job, so it's useful for this to be factored out.
This commit introduces a 'with_duplicate_xapian_job_creation'
method that can be passed a block which will be run with the forced
duplicate xapian job creation.
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/xapian_spec.rb | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/spec/models/xapian_spec.rb b/spec/models/xapian_spec.rb index c7c21e3a0..3c9fff784 100644 --- a/spec/models/xapian_spec.rb +++ b/spec/models/xapian_spec.rb @@ -406,28 +406,13 @@ describe InfoRequestEvent, " when faced with a race condition during xapian_mark before(:each) do load_raw_emails_data get_fixtures_xapian_index - # Use the before create job hook to simulate a race condition with another process - # by creating an acts_as_xapian_job record for the same model - class InfoRequestEvent - def xapian_before_create_job_hook(action, model, model_id) - ActsAsXapian::ActsAsXapianJob.create!(:model => model, - :model_id => model_id, - :action => action) - end - end - end - - after(:each) do - # Reset the before create job hook - class InfoRequestEvent - def xapian_before_create_job_hook(action, model, model_id) - end - end end it 'should not raise an error but should fail silently' do - ir = info_requests(:naughty_chicken_request) - ir.reindex_request_events + with_duplicate_xapian_job_creation do + ir = info_requests(:naughty_chicken_request) + ir.reindex_request_events + end end end |