diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-08-27 12:29:05 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-09-16 14:03:22 +0100 |
commit | fca2037a243a8e0b0afaf7fc779a96bb86f39b7f (patch) | |
tree | 4e1d2141296aa67d40817b3dc50c47c09658b793 | |
parent | e91443d8fab05b805fa781c701ca8616aeff563f (diff) |
InfoRequestEvent.indexed_by_search consults OutgoingMessage.
-rw-r--r-- | app/models/info_request_event.rb | 3 | ||||
-rw-r--r-- | spec/models/info_request_event_spec.rb | 19 |
2 files changed, 21 insertions, 1 deletions
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 8281f12a6..67cdda1b4 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -238,6 +238,9 @@ class InfoRequestEvent < ActiveRecord::Base if self.event_type == 'response' && !self.incoming_message.indexed_by_search? return false end + if ['sent', 'followup_sent'].include?(self.event_type) && !self.outgoing_message.indexed_by_search? + return false + end if self.event_type == 'comment' && !self.comment.visible return false end diff --git a/spec/models/info_request_event_spec.rb b/spec/models/info_request_event_spec.rb index 5feb3560a..53c83bd46 100644 --- a/spec/models/info_request_event_spec.rb +++ b/spec/models/info_request_event_spec.rb @@ -37,6 +37,7 @@ describe InfoRequestEvent do before do @comment = mock_model(Comment) @incoming_message = mock_model(IncomingMessage) + @outgoing_message = mock_model(OutgoingMessage) @info_request = mock_model(InfoRequest, :indexed_by_search? => true) end @@ -64,13 +65,29 @@ describe InfoRequestEvent do @info_request_event.indexed_by_search?.should be_false end - it 'should return true for an incoming message with prominence "normal"' do + it 'should return true for an incoming message that is indexed by search' 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 + + it 'should return false for an outgoing message that is not indexed by search' do + @outgoing_message.stub!(:indexed_by_search?).and_return false + @info_request_event = InfoRequestEvent.new(:event_type => 'followup_sent', + :outgoing_message => @outgoing_message, + :info_request => @info_request) + @info_request_event.indexed_by_search?.should be_false + end + + it 'should return true for an outgoing message that is indexed by search' do + @outgoing_message.stub!(:indexed_by_search?).and_return true + @info_request_event = InfoRequestEvent.new(:event_type => 'followup_sent', + :outgoing_message => @outgoing_message, + :info_request => @info_request) + @info_request_event.indexed_by_search?.should be_true + end end describe 'after saving' do |