aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/models/track_mailer_spec.rb25
-rw-r--r--spec/models/user_spec.rb42
2 files changed, 59 insertions, 8 deletions
diff --git a/spec/models/track_mailer_spec.rb b/spec/models/track_mailer_spec.rb
index 11e34c0cc..a2016f3d1 100644
--- a/spec/models/track_mailer_spec.rb
+++ b/spec/models/track_mailer_spec.rb
@@ -18,9 +18,11 @@ describe TrackMailer do
describe 'for each user' do
before do
- @user = mock_model(User, :last_daily_track_email= => true,
- :save! => true)
+ @user = mock_model(User, :no_reindex= => false,
+ :last_daily_track_email= => true,
+ :save! => true)
User.stub!(:find).and_return([@user])
+ @user.stub!(:no_reindex=)
end
it 'should ask for any daily track things for the user' do
@@ -29,6 +31,19 @@ describe TrackMailer do
TrackMailer.alert_tracks
end
+
+ it 'should set the no_reindex flag on the user' do
+ @user.should_receive(:no_reindex=).with(true)
+ TrackMailer.alert_tracks
+ end
+
+ it 'should update the time of the user\'s last daily tracking email' do
+ @user.should_receive(:last_daily_track_email=).with(Time.now)
+ @user.should_receive(:save!)
+ TrackMailer.alert_tracks
+ end
+
+
describe 'for each tracked thing' do
before do
@@ -84,12 +99,6 @@ describe TrackMailer do
TrackMailer.alert_tracks
end
end
-
- it 'should update the time of the user\'s last daily tracking email' do
- @user.should_receive(:last_daily_track_email=).with(Time.now)
- @user.should_receive(:save!)
- TrackMailer.alert_tracks
- end
end
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