Commit c4832b5fa4ee7d9e107581b36293536933350fd0
1 parent
89997cec
Exists in
master
and in
29 other branches
rails3: fix some profile tests
Showing
2 changed files
with
8 additions
and
6 deletions
Show diff stats
app/models/profile.rb
@@ -261,7 +261,7 @@ class Profile < ActiveRecord::Base | @@ -261,7 +261,7 @@ class Profile < ActiveRecord::Base | ||
261 | end | 261 | end |
262 | 262 | ||
263 | def country_name | 263 | def country_name |
264 | - CountriesHelper.instance.lookup(country) if respond_to?(:country) | 264 | + CountriesHelper::Object.instance.lookup(country) if respond_to?(:country) |
265 | end | 265 | end |
266 | 266 | ||
267 | def pending_categorizations | 267 | def pending_categorizations |
@@ -795,7 +795,9 @@ private :generate_url, :url_options | @@ -795,7 +795,9 @@ private :generate_url, :url_options | ||
795 | [] | 795 | [] |
796 | end | 796 | end |
797 | 797 | ||
798 | - def validate | 798 | + validate :image_valid |
799 | + | ||
800 | + def image_valid | ||
799 | unless self.image.nil? | 801 | unless self.image.nil? |
800 | self.image.valid? | 802 | self.image.valid? |
801 | self.image.errors.delete(:empty) # dont validate here if exists uploaded data | 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,7 +743,7 @@ class ProfileTest < ActiveSupport::TestCase | ||
743 | should 'nickname be able to be nil' do | 743 | should 'nickname be able to be nil' do |
744 | p = Profile.new() | 744 | p = Profile.new() |
745 | p.valid? | 745 | p.valid? |
746 | - assert_nil p.errors[:nickname] | 746 | + assert_blank p.errors[:nickname] |
747 | end | 747 | end |
748 | 748 | ||
749 | should 'filter html from nickname' do | 749 | should 'filter html from nickname' do |
@@ -1147,7 +1147,7 @@ class ProfileTest < ActiveSupport::TestCase | @@ -1147,7 +1147,7 @@ class ProfileTest < ActiveSupport::TestCase | ||
1147 | p2 = build(Profile, :identifier => 'mytestprofile', :environment => env) | 1147 | p2 = build(Profile, :identifier => 'mytestprofile', :environment => env) |
1148 | 1148 | ||
1149 | assert !p2.valid? | 1149 | assert !p2.valid? |
1150 | - assert p2.errors.on(:identifier) | 1150 | + assert p2.errors[:identifier] |
1151 | assert_equal p1.environment, p2.environment | 1151 | assert_equal p1.environment, p2.environment |
1152 | end | 1152 | end |
1153 | 1153 | ||
@@ -1324,13 +1324,13 @@ class ProfileTest < ActiveSupport::TestCase | @@ -1324,13 +1324,13 @@ class ProfileTest < ActiveSupport::TestCase | ||
1324 | should 'profile be valid when image is empty' do | 1324 | should 'profile be valid when image is empty' do |
1325 | profile = build(Profile, :image_builder => {:uploaded_data => ""}) | 1325 | profile = build(Profile, :image_builder => {:uploaded_data => ""}) |
1326 | profile.valid? | 1326 | profile.valid? |
1327 | - assert_nil profile.errors[:image] | 1327 | + assert_blank profile.errors[:image] |
1328 | end | 1328 | end |
1329 | 1329 | ||
1330 | should 'profile be valid when has no image' do | 1330 | should 'profile be valid when has no image' do |
1331 | profile = Profile.new | 1331 | profile = Profile.new |
1332 | profile.valid? | 1332 | profile.valid? |
1333 | - assert_nil profile.errors[:image] | 1333 | + assert_blank profile.errors[:image] |
1334 | end | 1334 | end |
1335 | 1335 | ||
1336 | should 'copy header and footer after create a person' do | 1336 | should 'copy header and footer after create a person' do |