diff options
-rw-r--r-- | app/models/incoming_message.rb | 7 | ||||
-rw-r--r-- | db/migrate/20130731145325_add_prominence_to_incoming_message.rb | 5 | ||||
-rw-r--r-- | spec/fixtures/incoming_messages.yml | 1 | ||||
-rw-r--r-- | spec/models/incoming_message_spec.rb | 21 |
4 files changed, 34 insertions, 0 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index cdb437a2d..fd7b226a6 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -17,6 +17,7 @@ # last_parsed :datetime # mail_from :text # sent_at :datetime +# prominence :string(255) default("normal"), not null # # models/incoming_message.rb: @@ -47,6 +48,12 @@ class IncomingMessage < ActiveRecord::Base belongs_to :raw_email + validates_inclusion_of :prominence, :in => [ + 'normal', + 'hidden', + 'requester_only' + ] + # See binary_mask_stuff function below. It just test for inclusion # in this hash, not the value of the right hand side. DoNotBinaryMask = { diff --git a/db/migrate/20130731145325_add_prominence_to_incoming_message.rb b/db/migrate/20130731145325_add_prominence_to_incoming_message.rb new file mode 100644 index 000000000..01c4906a7 --- /dev/null +++ b/db/migrate/20130731145325_add_prominence_to_incoming_message.rb @@ -0,0 +1,5 @@ +class AddProminenceToIncomingMessage < ActiveRecord::Migration + def change + add_column :incoming_messages, :prominence, :string, :null => false, :default => 'normal' + end +end diff --git a/spec/fixtures/incoming_messages.yml b/spec/fixtures/incoming_messages.yml index d56c509c9..dc161bdbe 100644 --- a/spec/fixtures/incoming_messages.yml +++ b/spec/fixtures/incoming_messages.yml @@ -16,6 +16,7 @@ # last_parsed :datetime # mail_from :text # sent_at :datetime +# prominence :string(255) default("normal"), not null # useless_incoming_message: diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb index 9455f20db..eda96f2a7 100644 --- a/spec/models/incoming_message_spec.rb +++ b/spec/models/incoming_message_spec.rb @@ -17,10 +17,31 @@ # last_parsed :datetime # mail_from :text # sent_at :datetime +# prominence :string(255) default("normal"), not null # require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +describe IncomingMessage, 'when validating' do + + it 'should be valid with valid prominence values' do + ['hidden', 'requester_only', 'normal'].each do |prominence| + incoming_message = IncomingMessage.new(:raw_email => RawEmail.new, + :info_request => InfoRequest.new, + :prominence => prominence) + incoming_message.valid?.should be_true + end + end + + it 'should not be valid with an invalid prominence value' do + incoming_message = IncomingMessage.new(:raw_email => RawEmail.new, + :info_request => InfoRequest.new, + :prominence => 'norman') + incoming_message.valid?.should be_false + end + +end + describe IncomingMessage, " when dealing with incoming mail" do before(:each) do |