diff options
author | louise <louise> | 2009-04-09 12:22:46 +0000 |
---|---|---|
committer | louise <louise> | 2009-04-09 12:22:46 +0000 |
commit | 522bc953d180fe405b2b53674dbb5d38d081ebe8 (patch) | |
tree | 719c6a15ff68fc911f3334b5372a448ac5ef9f52 /spec/models/user_spec.rb | |
parent | 4f7668980d16b55a2719be2cff83114e408d1d89 (diff) |
Adding a flag to allow user model to be saved without reindexing associated models
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r-- | spec/models/user_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 46aa046fb..5f29ebeb6 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -84,6 +84,48 @@ describe User, " when saving" do @user2.email = "flobble2@localhost" @user2.save! end + + +end + +describe User, "when reindexing referencing models" do + + before do + @request_event = mock_model(InfoRequestEvent, :xapian_mark_needs_index => true) + @request = mock_model(InfoRequest, :info_request_events => [@request_event]) + @comment_event = mock_model(InfoRequestEvent, :xapian_mark_needs_index => true) + @comment = mock_model(Comment, :info_request_events => [@comment_event]) + @user = User.new(:comments => [@comment], :info_requests => [@request]) + end + + it 'should reindex events associated with that user\'s comments' do + @comment_event.should_receive(:xapian_mark_needs_index) + @user.reindex_referencing_models + end + + it 'should reindex events associated with that user\'s requests' do + @request_event.should_receive(:xapian_mark_needs_index) + @user.reindex_referencing_models + end + + describe 'when no_reindex is set' do + + before do + @user.no_reindex = true + end + + it 'should not reindex events associated with that user\'s comments' do + @comment_event.should_not_receive(:xapian_mark_needs_index) + @user.reindex_referencing_models + end + + it 'should not reindex events associated with that user\'s requests' do + @request_event.should_not_receive(:xapian_mark_needs_index) + @user.reindex_referencing_models + end + + end + end describe User, "when checking abilities" do |