aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/info_request_event.rb6
-rw-r--r--spec/models/info_request_event_spec.rb25
2 files changed, 30 insertions, 1 deletions
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index 1a96723a0..8910b9997 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.rb
@@ -21,7 +21,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: info_request_event.rb,v 1.80 2009-04-15 18:15:30 louise Exp $
+# $Id: info_request_event.rb,v 1.81 2009-04-23 13:08:49 tony Exp $
class InfoRequestEvent < ActiveRecord::Base
belongs_to :info_request
@@ -195,6 +195,10 @@ class InfoRequestEvent < ActiveRecord::Base
YAML.load(self.params_yaml)
end
+ def is_incoming_message?() not self.incoming_message.nil? end
+ def is_outgoing_message?() not self.outgoing_message.nil? end
+ def is_comment?() not self.comment.nil? end
+
# Display version of status
def display_status
if !incoming_message.nil?
diff --git a/spec/models/info_request_event_spec.rb b/spec/models/info_request_event_spec.rb
index 428887c8b..fd263b2b8 100644
--- a/spec/models/info_request_event_spec.rb
+++ b/spec/models/info_request_event_spec.rb
@@ -25,5 +25,30 @@ describe InfoRequestEvent do
end
end
+
+ describe "should know" do
+
+ it "that it's an incoming message" do
+ event = InfoRequestEvent.new(:incoming_message => mock_model(IncomingMessage))
+ event.is_incoming_message?.should be_true
+ event.is_outgoing_message?.should be_false
+ event.is_comment?.should be_false
+ end
+
+ it "that it's an outgoing message" do
+ event = InfoRequestEvent.new(:outgoing_message => mock_model(OutgoingMessage))
+ event.is_incoming_message?.should be_false
+ event.is_outgoing_message?.should be_true
+ event.is_comment?.should be_false
+ end
+
+ it "that it's a comment" do
+ event = InfoRequestEvent.new(:comment => mock_model(Comment))
+ event.is_incoming_message?.should be_false
+ event.is_outgoing_message?.should be_false
+ event.is_comment?.should be_true
+ end
+
+ end
end