aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/info_request_event_spec.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-08-01 17:56:05 +0100
committerLouise Crow <louise.crow@gmail.com>2013-09-16 12:41:42 +0100
commita34e6b1e727c05052f3b4056d881622993d1da9a (patch)
tree64b58c808ccc6b375a41371afe4702497748fc8c /spec/models/info_request_event_spec.rb
parent86bac5f263be8adbf8a2fd32a558a8f80321fb57 (diff)
Don't index hidden and requester_only incoming messages.
Diffstat (limited to 'spec/models/info_request_event_spec.rb')
-rw-r--r--spec/models/info_request_event_spec.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/models/info_request_event_spec.rb b/spec/models/info_request_event_spec.rb
index 7f485454d..5feb3560a 100644
--- a/spec/models/info_request_event_spec.rb
+++ b/spec/models/info_request_event_spec.rb
@@ -32,6 +32,47 @@ describe InfoRequestEvent do
end
+ describe 'when deciding if it is indexed by search' do
+
+ before do
+ @comment = mock_model(Comment)
+ @incoming_message = mock_model(IncomingMessage)
+ @info_request = mock_model(InfoRequest, :indexed_by_search? => true)
+ end
+
+ it 'should return false for a comment that is not visible' do
+ @comment.stub!(:visible).and_return(false)
+ @info_request_event = InfoRequestEvent.new(:event_type => 'comment',
+ :comment => @comment,
+ :info_request => @info_request)
+ @info_request_event.indexed_by_search?.should be_false
+ end
+
+ it 'should return true for a comment that is visible' do
+ @comment.stub!(:visible).and_return(true)
+ @info_request_event = InfoRequestEvent.new(:event_type => 'comment',
+ :comment => @comment,
+ :info_request => @info_request)
+ @info_request_event.indexed_by_search?.should be_true
+ end
+
+ it 'should return false for an incoming message that is not indexed by search' do
+ @incoming_message.stub!(:indexed_by_search?).and_return false
+ @info_request_event = InfoRequestEvent.new(:event_type => 'response',
+ :incoming_message => @incoming_message,
+ :info_request => @info_request)
+ @info_request_event.indexed_by_search?.should be_false
+ end
+
+ it 'should return true for an incoming message with prominence "normal"' do
+ @incoming_message.stub!(:indexed_by_search?).and_return true
+ @info_request_event = InfoRequestEvent.new(:event_type => 'response',
+ :incoming_message => @incoming_message,
+ :info_request => @info_request)
+ @info_request_event.indexed_by_search?.should be_true
+ end
+ end
+
describe 'after saving' do
it 'should mark the model for reindexing in xapian if there is no no_xapian_reindex flag on the object' do