From c4832b5fa4ee7d9e107581b36293536933350fd0 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Wed, 15 Jan 2014 10:33:18 -0300 Subject: [PATCH] rails3: fix some profile tests --- app/models/profile.rb | 6 ++++-- test/unit/profile_test.rb | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/models/profile.rb b/app/models/profile.rb index 1963ed1..772008f 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -261,7 +261,7 @@ class Profile < ActiveRecord::Base end def country_name - CountriesHelper.instance.lookup(country) if respond_to?(:country) + CountriesHelper::Object.instance.lookup(country) if respond_to?(:country) end def pending_categorizations @@ -795,7 +795,9 @@ private :generate_url, :url_options [] end - def validate + validate :image_valid + + def image_valid unless self.image.nil? self.image.valid? self.image.errors.delete(:empty) # dont validate here if exists uploaded data diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index 53ac3ff..10102ff 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -743,7 +743,7 @@ class ProfileTest < ActiveSupport::TestCase should 'nickname be able to be nil' do p = Profile.new() p.valid? - assert_nil p.errors[:nickname] + assert_blank p.errors[:nickname] end should 'filter html from nickname' do @@ -1147,7 +1147,7 @@ class ProfileTest < ActiveSupport::TestCase p2 = build(Profile, :identifier => 'mytestprofile', :environment => env) assert !p2.valid? - assert p2.errors.on(:identifier) + assert p2.errors[:identifier] assert_equal p1.environment, p2.environment end @@ -1324,13 +1324,13 @@ class ProfileTest < ActiveSupport::TestCase should 'profile be valid when image is empty' do profile = build(Profile, :image_builder => {:uploaded_data => ""}) profile.valid? - assert_nil profile.errors[:image] + assert_blank profile.errors[:image] end should 'profile be valid when has no image' do profile = Profile.new profile.valid? - assert_nil profile.errors[:image] + assert_blank profile.errors[:image] end should 'copy header and footer after create a person' do -- libgit2 0.21.2