Commit c4832b5fa4ee7d9e107581b36293536933350fd0

Authored by Victor Costa
1 parent 89997cec

rails3: fix some profile tests

app/models/profile.rb
... ... @@ -261,7 +261,7 @@ class Profile < ActiveRecord::Base
261 261 end
262 262  
263 263 def country_name
264   - CountriesHelper.instance.lookup(country) if respond_to?(:country)
  264 + CountriesHelper::Object.instance.lookup(country) if respond_to?(:country)
265 265 end
266 266  
267 267 def pending_categorizations
... ... @@ -795,7 +795,9 @@ private :generate_url, :url_options
795 795 []
796 796 end
797 797  
798   - def validate
  798 + validate :image_valid
  799 +
  800 + def image_valid
799 801 unless self.image.nil?
800 802 self.image.valid?
801 803 self.image.errors.delete(:empty) # dont validate here if exists uploaded data
... ...
test/unit/profile_test.rb
... ... @@ -743,7 +743,7 @@ class ProfileTest < ActiveSupport::TestCase
743 743 should 'nickname be able to be nil' do
744 744 p = Profile.new()
745 745 p.valid?
746   - assert_nil p.errors[:nickname]
  746 + assert_blank p.errors[:nickname]
747 747 end
748 748  
749 749 should 'filter html from nickname' do
... ... @@ -1147,7 +1147,7 @@ class ProfileTest < ActiveSupport::TestCase
1147 1147 p2 = build(Profile, :identifier => 'mytestprofile', :environment => env)
1148 1148  
1149 1149 assert !p2.valid?
1150   - assert p2.errors.on(:identifier)
  1150 + assert p2.errors[:identifier]
1151 1151 assert_equal p1.environment, p2.environment
1152 1152 end
1153 1153  
... ... @@ -1324,13 +1324,13 @@ class ProfileTest < ActiveSupport::TestCase
1324 1324 should 'profile be valid when image is empty' do
1325 1325 profile = build(Profile, :image_builder => {:uploaded_data => ""})
1326 1326 profile.valid?
1327   - assert_nil profile.errors[:image]
  1327 + assert_blank profile.errors[:image]
1328 1328 end
1329 1329  
1330 1330 should 'profile be valid when has no image' do
1331 1331 profile = Profile.new
1332 1332 profile.valid?
1333   - assert_nil profile.errors[:image]
  1333 + assert_blank profile.errors[:image]
1334 1334 end
1335 1335  
1336 1336 should 'copy header and footer after create a person' do
... ...