diff options
-rw-r--r-- | app/models/incoming_message.rb | 4 | ||||
-rw-r--r-- | lib/message_prominence.rb | 4 | ||||
-rw-r--r-- | spec/models/outgoing_message_spec.rb | 25 |
3 files changed, 27 insertions, 6 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 85140398c..6d93dfcb9 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -73,10 +73,6 @@ class IncomingMessage < ActiveRecord::Base self.prominence == 'normal' end - def indexed_by_search? - self.prominence == 'normal' - end - # Return a cached structured mail object def mail(force = nil) if (!force.nil? || @mail.nil?) && !self.raw_email.nil? diff --git a/lib/message_prominence.rb b/lib/message_prominence.rb index cc70be3b1..9149a6b28 100644 --- a/lib/message_prominence.rb +++ b/lib/message_prominence.rb @@ -13,6 +13,10 @@ module MessageProminence Ability.can_view_with_prominence?(self.prominence, self.info_request, user) end + def indexed_by_search? + self.prominence == 'normal' + end + end end diff --git a/spec/models/outgoing_message_spec.rb b/spec/models/outgoing_message_spec.rb index 4bd9361a7..1e05e09f1 100644 --- a/spec/models/outgoing_message_spec.rb +++ b/spec/models/outgoing_message_spec.rb @@ -118,6 +118,29 @@ describe OutgoingMessage, " when making an outgoing message" do end + describe 'when asked if it is indexed by search' do + + before do + @info_request = FactoryGirl.create(:info_request) + @outgoing_message = @info_request.outgoing_messages.first + end + + it 'should return false if it has prominence "hidden"' do + @outgoing_message.prominence = 'hidden' + @outgoing_message.indexed_by_search?.should be_false + end + + it 'should return false if it has prominence "requester_only"' do + @outgoing_message.prominence = 'requester_only' + @outgoing_message.indexed_by_search?.should be_false + end + + it 'should return true if it has prominence "normal"' do + @outgoing_message.prominence = 'normal' + @outgoing_message.indexed_by_search?.should be_true + end + + end end @@ -140,5 +163,3 @@ describe IncomingMessage, " when censoring data" do @om.body.should match(/fancy cat/) end end - - |