Commit 861f38d9098fcebf16b765ef21959abdd5347024

Authored by AntonioTerceiro
1 parent a4bd1274

ActionItem96: adding contact e-mail for environment



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@617 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/environment.rb
... ... @@ -123,6 +123,8 @@ class Environment < ActiveRecord::Base
123 123 # only one environment can be the default one
124 124 validates_uniqueness_of :is_default, :if => (lambda do |environment| environment.is_default? end), :message => _('Only one Virtual Community can be the default one')
125 125  
  126 + validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT
  127 +
126 128 # #################################################
127 129 # Business logic in general
128 130 # #################################################
... ...
test/unit/environment_test.rb
... ... @@ -140,4 +140,17 @@ class EnvironmentTest < Test::Unit::TestCase
140 140 assert !env.display_categories.include?(cat2)
141 141 end
142 142  
  143 + should 'have a contact email' do
  144 + env = Environment.new
  145 + assert_nil env.contact_email
  146 +
  147 + env.contact_email = 'test'
  148 + env.valid?
  149 + assert env.errors.invalid?(:contact_email)
  150 +
  151 + env.contact_email = 'test@example.com'
  152 + env.valid?
  153 + assert !env.errors.invalid?(:contact_email)
  154 + end
  155 +
143 156 end
... ...