Commit f44afb44049f61b5336d67d2582ccff965813391
1 parent
a0b4958a
Exists in
master
and in
29 other branches
ActionItem500: s/nil/blank/
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2098 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
20 additions
and
1 deletions
Show diff stats
app/models/organization.rb
| ... | ... | @@ -44,7 +44,7 @@ class Organization < Profile |
| 44 | 44 | |
| 45 | 45 | validates_format_of :foundation_year, :with => Noosfero::Constants::INTEGER_FORMAT |
| 46 | 46 | |
| 47 | - validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |org| !org.contact_email.nil? }) | |
| 47 | + validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |org| !org.contact_email.blank? }) | |
| 48 | 48 | |
| 49 | 49 | xss_terminate :only => [ :acronym, :contact_person, :contact_email, :legal_form, :economic_activity, :management_information ] |
| 50 | 50 | ... | ... |
test/unit/organization_test.rb
| ... | ... | @@ -77,6 +77,25 @@ class OrganizationTest < Test::Unit::TestCase |
| 77 | 77 | assert_respond_to org, :contact_email |
| 78 | 78 | end |
| 79 | 79 | |
| 80 | + should 'validate contact_email if filled' do | |
| 81 | + org = Organization.new | |
| 82 | + org.valid? | |
| 83 | + assert !org.errors.invalid?(:contact_email) | |
| 84 | + | |
| 85 | + org.contact_email = '' | |
| 86 | + org.valid? | |
| 87 | + assert !org.errors.invalid?(:contact_email) | |
| 88 | + | |
| 89 | + | |
| 90 | + org.contact_email = 'invalid-email' | |
| 91 | + org.valid? | |
| 92 | + assert org.errors.invalid?(:contact_email) | |
| 93 | + | |
| 94 | + org.contact_email = 'someone@somedomain.com' | |
| 95 | + org.valid? | |
| 96 | + assert !org.errors.invalid?(:contact_email) | |
| 97 | + end | |
| 98 | + | |
| 80 | 99 | should 'list pending enterprise validations' do |
| 81 | 100 | org = Organization.new |
| 82 | 101 | assert_kind_of Array, org.pending_validations | ... | ... |