diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-08-27 12:28:10 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-09-16 14:03:22 +0100 |
commit | e91443d8fab05b805fa781c701ca8616aeff563f (patch) | |
tree | bd48900ce58866e58f245bf151da1ada8cd50e82 | |
parent | 798ba1a031c162b36bb1b4a61a431c7026fe1223 (diff) |
Move indexed_by_search to MessageProminence
Add some tests that it's working on the outgoing message model.
-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 - - |