From 1b306cc7e959cf69a0f3e5a388522a240c770cd9 Mon Sep 17 00:00:00 2001 From: louise Date: Tue, 14 Apr 2009 11:04:52 +0000 Subject: Allowing xapian reindexing to be skipped if a no_xapian_reindex flag is set on the model --- spec/models/user_spec.rb | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'spec/models/user_spec.rb') diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 5f29ebeb6..bf90ffdfb 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -84,10 +84,37 @@ describe User, " when saving" do @user2.email = "flobble2@localhost" @user2.save! end - + + it 'should mark the model for reindexing in xapian if the no_xapian_reindex flag is set to false' do + @user.name = "Mr. First" + @user.password = "insecurepassword" + @user.email = "reasonable@localhost" + @user.no_xapian_reindex = false + @user.should_receive(:xapian_mark_needs_index) + @user.save! + end + + it 'should mark the model for reindexing in xapian if the no_xapian_reindex flag is not set' do + @user.name = "Mr. Second" + @user.password = "insecurepassword" + @user.email = "reasonable@localhost" + @user.no_xapian_reindex = nil + @user.should_receive(:xapian_mark_needs_index) + @user.save! + end + + it 'should not mark the model for reindexing in xapian if the no_xapian_reindex flag is set' do + @user.name = "Mr. Third" + @user.password = "insecurepassword" + @user.email = "reasonable@localhost" + @user.no_xapian_reindex = true + @user.should_not_receive(:xapian_mark_needs_index) + @user.save! + end end + describe User, "when reindexing referencing models" do before do @@ -108,10 +135,10 @@ describe User, "when reindexing referencing models" do @user.reindex_referencing_models end - describe 'when no_reindex is set' do + describe 'when no_xapian_reindex is set' do before do - @user.no_reindex = true + @user.no_xapian_reindex = true end it 'should not reindex events associated with that user\'s comments' do -- cgit v1.2.3