Commit 6d2a0edf0ec3ab1d1f07cac36cc5b29d5d48c3ba
1 parent
4001b435
Exists in
staging
and in
42 other branches
rails3: refactor deprecated invalid? of ActiveRecord::Errors from all tests
Showing
32 changed files
with
225 additions
and
225 deletions
Show diff stats
test/test_helper.rb
| ... | ... | @@ -95,16 +95,16 @@ class ActiveSupport::TestCase |
| 95 | 95 | def assert_mandatory(object, attribute, test_value = 'some random string') |
| 96 | 96 | object.send("#{attribute}=", nil) |
| 97 | 97 | object.valid? |
| 98 | - assert object.errors.invalid?(attribute), "Attribute \"#{attribute.to_s}\" expected to be mandatory." | |
| 98 | + assert object.errors[attribute.to_s].present?, "Attribute \"#{attribute.to_s}\" expected to be mandatory." | |
| 99 | 99 | object.send("#{attribute}=", test_value) |
| 100 | 100 | object.valid? |
| 101 | - assert !object.errors.invalid?(attribute), "Attribute \"#{attribute.to_s}\" expected to accept value #{test_value.inspect}" | |
| 101 | + assert !object.errors[attribute.to_s].present?, "Attribute \"#{attribute.to_s}\" expected to accept value #{test_value.inspect}" | |
| 102 | 102 | end |
| 103 | 103 | |
| 104 | 104 | def assert_optional(object, attribute) |
| 105 | 105 | object.send("#{attribute}=", nil) |
| 106 | 106 | object.valid? |
| 107 | - assert !object.errors.invalid?(attribute) | |
| 107 | + assert !object.errors[attribute.to_s].present? | |
| 108 | 108 | end |
| 109 | 109 | |
| 110 | 110 | def assert_subclass(parent, child) | ... | ... |
test/unit/action_tracker_notification_test.rb
| ... | ... | @@ -5,21 +5,21 @@ class ActionTrackerNotificationTest < ActiveSupport::TestCase |
| 5 | 5 | should "have the profile" do |
| 6 | 6 | a = ActionTrackerNotification.new |
| 7 | 7 | a.valid? |
| 8 | - assert a.errors.invalid?(:profile_id) | |
| 8 | + assert a.errors[:profile_id.to_s].present? | |
| 9 | 9 | |
| 10 | 10 | a.profile_id= 1 |
| 11 | 11 | a.valid? |
| 12 | - assert !a.errors.invalid?(:profile_id) | |
| 12 | + assert !a.errors[:profile_id.to_s].present? | |
| 13 | 13 | end |
| 14 | 14 | |
| 15 | 15 | should "have the action tracker" do |
| 16 | 16 | a = ActionTrackerNotification.new |
| 17 | 17 | a.valid? |
| 18 | - assert a.errors.invalid?(:action_tracker_id) | |
| 18 | + assert a.errors[:action_tracker_id.to_s].present? | |
| 19 | 19 | |
| 20 | 20 | a.action_tracker_id= 1 |
| 21 | 21 | a.valid? |
| 22 | - assert !a.errors.invalid?(:action_tracker_id) | |
| 22 | + assert !a.errors[:action_tracker_id.to_s].present? | |
| 23 | 23 | end |
| 24 | 24 | |
| 25 | 25 | should "be associated to Person" do |
| ... | ... | @@ -54,11 +54,11 @@ class ActionTrackerNotificationTest < ActiveSupport::TestCase |
| 54 | 54 | |
| 55 | 55 | atn = ActionTrackerNotification.new(:action_tracker_id => 1, :profile_id => 1) |
| 56 | 56 | atn.valid? |
| 57 | - assert atn.errors.invalid?(:action_tracker_id) | |
| 57 | + assert atn.errors[:action_tracker_id.to_s].present? | |
| 58 | 58 | |
| 59 | 59 | atn.profile_id = 2 |
| 60 | 60 | atn.valid? |
| 61 | - assert !atn.errors.invalid?(:action_tracker_id) | |
| 61 | + assert !atn.errors[:action_tracker_id.to_s].present? | |
| 62 | 62 | end |
| 63 | 63 | |
| 64 | 64 | should "the action_tracker_id be unique on scope of profile when created by ActionTracker::Record association" do | ... | ... |
test/unit/add_friend_test.rb
| ... | ... | @@ -44,11 +44,11 @@ class AddFriendTest < ActiveSupport::TestCase |
| 44 | 44 | task = AddFriend.new |
| 45 | 45 | task.valid? |
| 46 | 46 | |
| 47 | - ok('must not validate with empty requestor') { task.errors.invalid?(:requestor_id) } | |
| 47 | + ok('must not validate with empty requestor') { task.errors[:requestor_id.to_s].present? } | |
| 48 | 48 | |
| 49 | 49 | task.requestor = Person.new |
| 50 | 50 | task.valid? |
| 51 | - ok('must validate when requestor is given') { task.errors.invalid?(:requestor_id)} | |
| 51 | + ok('must validate when requestor is given') { task.errors[:requestor_id.to_s].present?} | |
| 52 | 52 | |
| 53 | 53 | end |
| 54 | 54 | |
| ... | ... | @@ -56,11 +56,11 @@ class AddFriendTest < ActiveSupport::TestCase |
| 56 | 56 | task = AddFriend.new |
| 57 | 57 | task.valid? |
| 58 | 58 | |
| 59 | - ok('must not validate with empty target') { task.errors.invalid?(:target_id) } | |
| 59 | + ok('must not validate with empty target') { task.errors[:target_id.to_s].present? } | |
| 60 | 60 | |
| 61 | 61 | task.target = Person.new |
| 62 | 62 | task.valid? |
| 63 | - ok('must validate when target is given') { task.errors.invalid?(:target_id)} | |
| 63 | + ok('must validate when target is given') { task.errors[:target_id.to_s].present?} | |
| 64 | 64 | end |
| 65 | 65 | |
| 66 | 66 | should 'send e-mails' do | ... | ... |
test/unit/add_member_test.rb
| ... | ... | @@ -34,22 +34,22 @@ class AddMemberTest < ActiveSupport::TestCase |
| 34 | 34 | task = AddMember.new |
| 35 | 35 | task.valid? |
| 36 | 36 | |
| 37 | - ok('must not validate with empty requestor') { task.errors.invalid?(:requestor_id) } | |
| 37 | + ok('must not validate with empty requestor') { task.errors[:requestor_id.to_s].present? } | |
| 38 | 38 | |
| 39 | 39 | task.requestor = Person.new |
| 40 | 40 | task.valid? |
| 41 | - ok('must validate when requestor is given') { task.errors.invalid?(:requestor_id)} | |
| 41 | + ok('must validate when requestor is given') { task.errors[:requestor_id.to_s].present?} | |
| 42 | 42 | end |
| 43 | 43 | |
| 44 | 44 | should 'require target' do |
| 45 | 45 | task = AddMember.new |
| 46 | 46 | task.valid? |
| 47 | 47 | |
| 48 | - ok('must not validate with empty target') { task.errors.invalid?(:target_id) } | |
| 48 | + ok('must not validate with empty target') { task.errors[:target_id.to_s].present? } | |
| 49 | 49 | |
| 50 | 50 | task.target = Person.new |
| 51 | 51 | task.valid? |
| 52 | - ok('must validate when target is given') { task.errors.invalid?(:target_id)} | |
| 52 | + ok('must validate when target is given') { task.errors[:target_id.to_s].present?} | |
| 53 | 53 | end |
| 54 | 54 | |
| 55 | 55 | should 'send e-mails' do | ... | ... |
test/unit/approve_comment_test.rb
| ... | ... | @@ -91,11 +91,11 @@ class ApproveCommentTest < ActiveSupport::TestCase |
| 91 | 91 | task = ApproveComment.new |
| 92 | 92 | task.valid? |
| 93 | 93 | |
| 94 | - ok('must not validate with empty target') { task.errors.invalid?(:target_id) } | |
| 94 | + ok('must not validate with empty target') { task.errors[:target_id.to_s].present? } | |
| 95 | 95 | |
| 96 | 96 | task.target = Person.new |
| 97 | 97 | task.valid? |
| 98 | - ok('must validate when target is given') { task.errors.invalid?(:target_id)} | |
| 98 | + ok('must validate when target is given') { task.errors[:target_id.to_s].present?} | |
| 99 | 99 | end |
| 100 | 100 | |
| 101 | 101 | should 'send e-mails' do | ... | ... |
test/unit/article_test.rb
| ... | ... | @@ -13,31 +13,31 @@ class ArticleTest < ActiveSupport::TestCase |
| 13 | 13 | should 'have and require an associated profile' do |
| 14 | 14 | a = Article.new |
| 15 | 15 | a.valid? |
| 16 | - assert a.errors.invalid?(:profile_id) | |
| 16 | + assert a.errors[:profile_id.to_s].present? | |
| 17 | 17 | |
| 18 | 18 | a.profile = profile |
| 19 | 19 | a.valid? |
| 20 | - assert !a.errors.invalid?(:profile_id) | |
| 20 | + assert !a.errors[:profile_id.to_s].present? | |
| 21 | 21 | end |
| 22 | 22 | |
| 23 | 23 | should 'require value for name' do |
| 24 | 24 | a = Article.new |
| 25 | 25 | a.valid? |
| 26 | - assert a.errors.invalid?(:name) | |
| 26 | + assert a.errors[:name.to_s].present? | |
| 27 | 27 | |
| 28 | 28 | a.name = 'my article' |
| 29 | 29 | a.valid? |
| 30 | - assert !a.errors.invalid?(:name) | |
| 30 | + assert !a.errors[:name.to_s].present? | |
| 31 | 31 | end |
| 32 | 32 | |
| 33 | 33 | should 'limit length of names' do |
| 34 | 34 | a = Article.new(:name => 'a'*151) |
| 35 | 35 | a.valid? |
| 36 | - assert a.errors.invalid?(:name) | |
| 36 | + assert a.errors[:name.to_s].present? | |
| 37 | 37 | |
| 38 | 38 | a.name = 'a'*150 |
| 39 | 39 | a.valid? |
| 40 | - assert !a.errors.invalid?(:name) | |
| 40 | + assert !a.errors[:name.to_s].present? | |
| 41 | 41 | end |
| 42 | 42 | |
| 43 | 43 | should 'require value for slug and path if name is filled' do |
| ... | ... | @@ -45,15 +45,15 @@ class ArticleTest < ActiveSupport::TestCase |
| 45 | 45 | a.slug = nil |
| 46 | 46 | a.path = nil |
| 47 | 47 | a.valid? |
| 48 | - assert a.errors.invalid?(:slug) | |
| 49 | - assert a.errors.invalid?(:path) | |
| 48 | + assert a.errors[:slug.to_s].present? | |
| 49 | + assert a.errors[:path.to_s].present? | |
| 50 | 50 | end |
| 51 | 51 | |
| 52 | 52 | should 'not require value for slug and path if name is blank' do |
| 53 | 53 | a = Article.new |
| 54 | 54 | a.valid? |
| 55 | - assert !a.errors.invalid?(:slug) | |
| 56 | - assert !a.errors.invalid?(:path) | |
| 55 | + assert !a.errors[:slug.to_s].present? | |
| 56 | + assert !a.errors[:path.to_s].present? | |
| 57 | 57 | end |
| 58 | 58 | |
| 59 | 59 | should 'act as versioned' do |
| ... | ... | @@ -136,20 +136,20 @@ class ArticleTest < ActiveSupport::TestCase |
| 136 | 136 | # cannot add another top level article with same slug |
| 137 | 137 | a2 = profile.articles.build(:name => 'test') |
| 138 | 138 | a2.valid? |
| 139 | - assert a2.errors.invalid?(:slug) | |
| 139 | + assert a2.errors[:slug.to_s].present? | |
| 140 | 140 | |
| 141 | 141 | # now create a child of a1 |
| 142 | 142 | a3 = profile.articles.build(:name => 'test') |
| 143 | 143 | a3.parent = a1 |
| 144 | 144 | a3.valid? |
| 145 | - assert !a3.errors.invalid?(:slug) | |
| 145 | + assert !a3.errors[:slug.to_s].present? | |
| 146 | 146 | a3.save! |
| 147 | 147 | |
| 148 | 148 | # cannot add another child of a1 with same slug |
| 149 | 149 | a4 = profile.articles.build(:name => 'test') |
| 150 | 150 | a4.parent = a1 |
| 151 | 151 | a4.valid? |
| 152 | - assert a4.errors.invalid?(:slug) | |
| 152 | + assert a4.errors[:slug.to_s].present? | |
| 153 | 153 | end |
| 154 | 154 | |
| 155 | 155 | should 'record who did the last change' do |
| ... | ... | @@ -1218,19 +1218,19 @@ class ArticleTest < ActiveSupport::TestCase |
| 1218 | 1218 | a = build(Article, :profile_id => fast_create(Profile).id) |
| 1219 | 1219 | a.language = '12' |
| 1220 | 1220 | a.valid? |
| 1221 | - assert a.errors.invalid?(:language) | |
| 1221 | + assert a.errors[:language.to_s].present? | |
| 1222 | 1222 | a.language = 'en' |
| 1223 | 1223 | a.valid? |
| 1224 | - assert !a.errors.invalid?(:language) | |
| 1224 | + assert !a.errors[:language.to_s].present? | |
| 1225 | 1225 | end |
| 1226 | 1226 | |
| 1227 | 1227 | should 'language can be blank' do |
| 1228 | 1228 | a = build(Article) |
| 1229 | 1229 | a.valid? |
| 1230 | - assert !a.errors.invalid?(:language) | |
| 1230 | + assert !a.errors[:language.to_s].present? | |
| 1231 | 1231 | a.language = '' |
| 1232 | 1232 | a.valid? |
| 1233 | - assert !a.errors.invalid?(:language) | |
| 1233 | + assert !a.errors[:language.to_s].present? | |
| 1234 | 1234 | end |
| 1235 | 1235 | |
| 1236 | 1236 | should 'article is not translatable' do |
| ... | ... | @@ -1261,10 +1261,10 @@ class ArticleTest < ActiveSupport::TestCase |
| 1261 | 1261 | a.language = 'en' |
| 1262 | 1262 | a.translation_of = native_article |
| 1263 | 1263 | a.valid? |
| 1264 | - assert a.errors.invalid?(:language) | |
| 1264 | + assert a.errors[:language.to_s].present? | |
| 1265 | 1265 | a.language = 'es' |
| 1266 | 1266 | a.valid? |
| 1267 | - assert !a.errors.invalid?(:language) | |
| 1267 | + assert !a.errors[:language.to_s].present? | |
| 1268 | 1268 | end |
| 1269 | 1269 | |
| 1270 | 1270 | should 'verify if native translation is already in use' do |
| ... | ... | @@ -1273,10 +1273,10 @@ class ArticleTest < ActiveSupport::TestCase |
| 1273 | 1273 | a.language = 'pt' |
| 1274 | 1274 | a.translation_of = native_article |
| 1275 | 1275 | a.valid? |
| 1276 | - assert a.errors.invalid?(:language) | |
| 1276 | + assert a.errors[:language.to_s].present? | |
| 1277 | 1277 | a.language = 'es' |
| 1278 | 1278 | a.valid? |
| 1279 | - assert !a.errors.invalid?(:language) | |
| 1279 | + assert !a.errors[:language.to_s].present? | |
| 1280 | 1280 | end |
| 1281 | 1281 | |
| 1282 | 1282 | should 'translation have a language' do |
| ... | ... | @@ -1284,10 +1284,10 @@ class ArticleTest < ActiveSupport::TestCase |
| 1284 | 1284 | a = build(Article, :profile_id => fast_create(Profile).id) |
| 1285 | 1285 | a.translation_of = native_article |
| 1286 | 1286 | a.valid? |
| 1287 | - assert a.errors.invalid?(:language) | |
| 1287 | + assert a.errors[:language.to_s].present? | |
| 1288 | 1288 | a.language = 'en' |
| 1289 | 1289 | a.valid? |
| 1290 | - assert !a.errors.invalid?(:language) | |
| 1290 | + assert !a.errors[:language.to_s].present? | |
| 1291 | 1291 | end |
| 1292 | 1292 | |
| 1293 | 1293 | should 'native translation have a language' do |
| ... | ... | @@ -1714,7 +1714,7 @@ class ArticleTest < ActiveSupport::TestCase |
| 1714 | 1714 | article.parent = article |
| 1715 | 1715 | article.valid? |
| 1716 | 1716 | |
| 1717 | - assert article.errors.invalid?(:parent_id) | |
| 1717 | + assert article.errors[:parent_id.to_s].present? | |
| 1718 | 1718 | end |
| 1719 | 1719 | |
| 1720 | 1720 | should 'not allow cyclical paternity' do |
| ... | ... | @@ -1724,7 +1724,7 @@ class ArticleTest < ActiveSupport::TestCase |
| 1724 | 1724 | a1.parent = a3 |
| 1725 | 1725 | a1.valid? |
| 1726 | 1726 | |
| 1727 | - assert a1.errors.invalid?(:parent_id) | |
| 1727 | + assert a1.errors[:parent_id.to_s].present? | |
| 1728 | 1728 | end |
| 1729 | 1729 | |
| 1730 | 1730 | should 'set author_name before creating article if there is an author' do | ... | ... |
test/unit/blog_test.rb
| ... | ... | @@ -164,15 +164,15 @@ class BlogTest < ActiveSupport::TestCase |
| 164 | 164 | blog = Blog.new(:name => 'blog') |
| 165 | 165 | blog.visualization_format = 'wrong_format' |
| 166 | 166 | blog.valid? |
| 167 | - assert blog.errors.invalid?(:visualization_format) | |
| 167 | + assert blog.errors[:visualization_format.to_s].present? | |
| 168 | 168 | |
| 169 | 169 | blog.visualization_format = 'short' |
| 170 | 170 | blog.valid? |
| 171 | - assert !blog.errors.invalid?(:visualization_format) | |
| 171 | + assert !blog.errors[:visualization_format.to_s].present? | |
| 172 | 172 | |
| 173 | 173 | blog.visualization_format = 'full' |
| 174 | 174 | blog.valid? |
| 175 | - assert !blog.errors.invalid?(:visualization_format) | |
| 175 | + assert !blog.errors[:visualization_format.to_s].present? | |
| 176 | 176 | end |
| 177 | 177 | |
| 178 | 178 | should 'have posts' do | ... | ... |
test/unit/category_test.rb
| ... | ... | @@ -11,14 +11,14 @@ class CategoryTest < ActiveSupport::TestCase |
| 11 | 11 | c = Category.new |
| 12 | 12 | c.organization = @env |
| 13 | 13 | c.save |
| 14 | - assert c.errors.invalid?(:name) | |
| 14 | + assert c.errors[:name.to_s].present? | |
| 15 | 15 | end |
| 16 | 16 | |
| 17 | 17 | def test_mandatory_field_name |
| 18 | 18 | c = Category.new |
| 19 | 19 | c.name = 'product category for testing' |
| 20 | 20 | assert !c.valid? |
| 21 | - assert c.errors.invalid?(:environment_id) | |
| 21 | + assert c.errors[:environment_id.to_s].present? | |
| 22 | 22 | end |
| 23 | 23 | |
| 24 | 24 | def test_relationship_with_environment |
| ... | ... | @@ -136,7 +136,7 @@ class CategoryTest < ActiveSupport::TestCase |
| 136 | 136 | c2 = Category.new(:name => 'Test: Category', :environment_id => @env.id) |
| 137 | 137 | |
| 138 | 138 | assert !c2.valid? |
| 139 | - assert c2.errors.invalid?(:slug) | |
| 139 | + assert c2.errors[:slug.to_s].present? | |
| 140 | 140 | end |
| 141 | 141 | |
| 142 | 142 | should 'be able to duplicated slug in different scope' do |
| ... | ... | @@ -170,13 +170,13 @@ class CategoryTest < ActiveSupport::TestCase |
| 170 | 170 | |
| 171 | 171 | c.display_color = 10 |
| 172 | 172 | c.valid? |
| 173 | - assert c.errors.invalid?(:display_color) | |
| 173 | + assert c.errors[:display_color.to_s].present? | |
| 174 | 174 | |
| 175 | 175 | valid = %w[ 1 2 3 4 ].map { |item| item.to_i } |
| 176 | 176 | valid.each do |item| |
| 177 | 177 | c.display_color = item |
| 178 | 178 | c.valid? |
| 179 | - assert !c.errors.invalid?(:display_color) | |
| 179 | + assert !c.errors[:display_color.to_s].present? | |
| 180 | 180 | end |
| 181 | 181 | |
| 182 | 182 | end |
| ... | ... | @@ -187,11 +187,11 @@ class CategoryTest < ActiveSupport::TestCase |
| 187 | 187 | c = Category.new(:name => 'lalala', :environment_id => @env.id) |
| 188 | 188 | c.display_color = 1 |
| 189 | 189 | assert !c.valid? |
| 190 | - assert c.errors.invalid?(:display_color) | |
| 190 | + assert c.errors[:display_color.to_s].present? | |
| 191 | 191 | |
| 192 | 192 | c.display_color = 2 |
| 193 | 193 | c.valid? |
| 194 | - assert !c.errors.invalid?(:display_color) | |
| 194 | + assert !c.errors[:display_color.to_s].present? | |
| 195 | 195 | |
| 196 | 196 | end |
| 197 | 197 | ... | ... |
test/unit/change_password_test.rb
| ... | ... | @@ -17,7 +17,7 @@ class ChangePasswordTest < ActiveSupport::TestCase |
| 17 | 17 | data.email = 'example@example.com' |
| 18 | 18 | data.environment_id = Environment.default.id |
| 19 | 19 | data.valid? |
| 20 | - assert data.errors.invalid?(:login) | |
| 20 | + assert data.errors[:login.to_s].present? | |
| 21 | 21 | end |
| 22 | 22 | |
| 23 | 23 | should 'require a valid username' do |
| ... | ... | @@ -27,7 +27,7 @@ class ChangePasswordTest < ActiveSupport::TestCase |
| 27 | 27 | data = ChangePassword.new |
| 28 | 28 | data.login = 'testuser' |
| 29 | 29 | data.valid? |
| 30 | - assert !data.errors.invalid?(:login) | |
| 30 | + assert !data.errors[:login.to_s].present? | |
| 31 | 31 | end |
| 32 | 32 | |
| 33 | 33 | should 'refuse incorrect e-mail address' do |
| ... | ... | @@ -40,8 +40,8 @@ class ChangePasswordTest < ActiveSupport::TestCase |
| 40 | 40 | data.environment_id = Environment.default.id |
| 41 | 41 | |
| 42 | 42 | data.valid? |
| 43 | - assert !data.errors.invalid?(:login) | |
| 44 | - assert data.errors.invalid?(:email) | |
| 43 | + assert !data.errors[:login.to_s].present? | |
| 44 | + assert data.errors[:email.to_s].present? | |
| 45 | 45 | end |
| 46 | 46 | |
| 47 | 47 | should 'require the correct e-mail address' do |
| ... | ... | @@ -54,8 +54,8 @@ class ChangePasswordTest < ActiveSupport::TestCase |
| 54 | 54 | data.environment_id = Environment.default.id |
| 55 | 55 | |
| 56 | 56 | data.valid? |
| 57 | - assert !data.errors.invalid?(:login) | |
| 58 | - assert !data.errors.invalid?(:email) | |
| 57 | + assert !data.errors[:login.to_s].present? | |
| 58 | + assert !data.errors[:email.to_s].present? | |
| 59 | 59 | end |
| 60 | 60 | |
| 61 | 61 | should 'require correct passsword confirmation' do |
| ... | ... | @@ -71,7 +71,7 @@ class ChangePasswordTest < ActiveSupport::TestCase |
| 71 | 71 | change.password = 'right' |
| 72 | 72 | change.password_confirmation = 'wrong' |
| 73 | 73 | assert !change.valid? |
| 74 | - assert change.errors.invalid?(:password) | |
| 74 | + assert change.errors[:password.to_s].present? | |
| 75 | 75 | |
| 76 | 76 | |
| 77 | 77 | change.password_confirmation = 'right' | ... | ... |
test/unit/comment_test.rb
| ... | ... | @@ -59,7 +59,7 @@ class CommentTest < ActiveSupport::TestCase |
| 59 | 59 | c1.author = create_user('someperson').person |
| 60 | 60 | c1.name = 'my name' |
| 61 | 61 | c1.valid? |
| 62 | - assert c1.errors.invalid?(:name) | |
| 62 | + assert c1.errors[:name.to_s].present? | |
| 63 | 63 | assert_no_match /\{fn\}/, c1.errors.on(:name) |
| 64 | 64 | end |
| 65 | 65 | |
| ... | ... | @@ -172,7 +172,7 @@ class CommentTest < ActiveSupport::TestCase |
| 172 | 172 | should 'not accept invalid email' do |
| 173 | 173 | c = Comment.new(:name => 'My Name', :email => 'my@invalid') |
| 174 | 174 | c.valid? |
| 175 | - assert c.errors.invalid?(:email) | |
| 175 | + assert c.errors[:email.to_s].present? | |
| 176 | 176 | end |
| 177 | 177 | |
| 178 | 178 | should 'generate links to comments on images with view set to true' do |
| ... | ... | @@ -197,8 +197,8 @@ class CommentTest < ActiveSupport::TestCase |
| 197 | 197 | comment = article.comments.new(:title => '<h1 title </h1>', :body => '<h1 body </h1>', :name => '<h1 name </h1>', :email => 'cracker@test.org') |
| 198 | 198 | comment.valid? |
| 199 | 199 | |
| 200 | - assert comment.errors.invalid?(:name) | |
| 201 | - assert comment.errors.invalid?(:body) | |
| 200 | + assert comment.errors[:name.to_s].present? | |
| 201 | + assert comment.errors[:body.to_s].present? | |
| 202 | 202 | end |
| 203 | 203 | |
| 204 | 204 | should 'escape malformed html tags' do | ... | ... |
test/unit/community_test.rb
| ... | ... | @@ -117,11 +117,11 @@ class CommunityTest < ActiveSupport::TestCase |
| 117 | 117 | e.expects(:required_community_fields).returns(['contact_phone']).at_least_once |
| 118 | 118 | community = Community.new(:name => 'My community', :environment => e) |
| 119 | 119 | assert ! community.valid? |
| 120 | - assert community.errors.invalid?(:contact_phone) | |
| 120 | + assert community.errors[:contact_phone.to_s].present? | |
| 121 | 121 | |
| 122 | 122 | community.contact_phone = '99999' |
| 123 | 123 | community.valid? |
| 124 | - assert ! community.errors.invalid?(:contact_phone) | |
| 124 | + assert ! community.errors[:contact_phone.to_s].present? | |
| 125 | 125 | end |
| 126 | 126 | |
| 127 | 127 | should 'return newest text articles as news' do | ... | ... |
test/unit/create_community_test.rb
| ... | ... | @@ -20,10 +20,10 @@ class CreateCommunityTest < ActiveSupport::TestCase |
| 20 | 20 | task = CreateCommunity.new(:name => 'community test', :target => Environment.default) |
| 21 | 21 | task.valid? |
| 22 | 22 | |
| 23 | - assert task.errors.invalid?(:requestor_id) | |
| 23 | + assert task.errors[:requestor_id.to_s].present? | |
| 24 | 24 | task.requestor = person |
| 25 | 25 | task.valid? |
| 26 | - assert !task.errors.invalid?(:requestor_id) | |
| 26 | + assert !task.errors[:requestor_id.to_s].present? | |
| 27 | 27 | end |
| 28 | 28 | |
| 29 | 29 | should 'actually create a community when finishing the task and associate the task requestor as its admin' do | ... | ... |
test/unit/create_enterprise_test.rb
| ... | ... | @@ -22,11 +22,11 @@ class CreateEnterpriseTest < ActiveSupport::TestCase |
| 22 | 22 | |
| 23 | 23 | task.foundation_year = "test" |
| 24 | 24 | task.valid? |
| 25 | - assert task.errors.invalid?(:foundation_year) | |
| 25 | + assert task.errors[:foundation_year.to_s].present? | |
| 26 | 26 | |
| 27 | 27 | task.foundation_year = 2006 |
| 28 | 28 | task.valid? |
| 29 | - assert !task.errors.invalid?(:foundation_year) | |
| 29 | + assert !task.errors[:foundation_year.to_s].present? | |
| 30 | 30 | end |
| 31 | 31 | |
| 32 | 32 | should 'require a requestor' do |
| ... | ... | @@ -34,10 +34,10 @@ class CreateEnterpriseTest < ActiveSupport::TestCase |
| 34 | 34 | task.stubs(:environment).returns(Environment.default) |
| 35 | 35 | task.valid? |
| 36 | 36 | |
| 37 | - assert task.errors.invalid?(:requestor_id) | |
| 37 | + assert task.errors[:requestor_id.to_s].present? | |
| 38 | 38 | task.requestor = create_user('testuser').person |
| 39 | 39 | task.valid? |
| 40 | - assert !task.errors.invalid?(:requestor_id) | |
| 40 | + assert !task.errors[:requestor_id.to_s].present? | |
| 41 | 41 | end |
| 42 | 42 | |
| 43 | 43 | should 'require a target (validator organization)' do |
| ... | ... | @@ -45,11 +45,11 @@ class CreateEnterpriseTest < ActiveSupport::TestCase |
| 45 | 45 | task.stubs(:environment).returns(Environment.default) |
| 46 | 46 | task.valid? |
| 47 | 47 | |
| 48 | - assert task.errors.invalid?(:target_id) | |
| 48 | + assert task.errors[:target_id.to_s].present? | |
| 49 | 49 | task.target = Organization.create!(:name => "My organization", :identifier => 'validator_organization') |
| 50 | 50 | |
| 51 | 51 | task.valid? |
| 52 | - assert !task.errors.invalid?(:target_id) | |
| 52 | + assert !task.errors[:target_id.to_s].present? | |
| 53 | 53 | end |
| 54 | 54 | |
| 55 | 55 | should 'require that the informed target (validator organization) actually validates for the chosen region' do |
| ... | ... | @@ -64,12 +64,12 @@ class CreateEnterpriseTest < ActiveSupport::TestCase |
| 64 | 64 | task.target = validator |
| 65 | 65 | |
| 66 | 66 | task.valid? |
| 67 | - assert task.errors.invalid?(:target) | |
| 67 | + assert task.errors[:target.to_s].present? | |
| 68 | 68 | |
| 69 | 69 | region.validators << validator |
| 70 | 70 | |
| 71 | 71 | task.valid? |
| 72 | - assert !task.errors.invalid?(:target) | |
| 72 | + assert !task.errors[:target.to_s].present? | |
| 73 | 73 | end |
| 74 | 74 | |
| 75 | 75 | should 'cancel task when rejected ' do |
| ... | ... | @@ -84,15 +84,15 @@ class CreateEnterpriseTest < ActiveSupport::TestCase |
| 84 | 84 | task.reject_explanation = nil |
| 85 | 85 | |
| 86 | 86 | task.valid? |
| 87 | - assert !task.errors.invalid?(:reject_explanation) | |
| 87 | + assert !task.errors[:reject_explanation.to_s].present? | |
| 88 | 88 | |
| 89 | 89 | task.status = Task::Status::CANCELLED |
| 90 | 90 | task.valid? |
| 91 | - assert task.errors.invalid?(:reject_explanation) | |
| 91 | + assert task.errors[:reject_explanation.to_s].present? | |
| 92 | 92 | |
| 93 | 93 | task.reject_explanation = 'bla bla bla' |
| 94 | 94 | task.valid? |
| 95 | - assert !task.errors.invalid?(:reject_explanation) | |
| 95 | + assert !task.errors[:reject_explanation.to_s].present? | |
| 96 | 96 | end |
| 97 | 97 | |
| 98 | 98 | should 'finish task when approved' do |
| ... | ... | @@ -232,11 +232,11 @@ class CreateEnterpriseTest < ActiveSupport::TestCase |
| 232 | 232 | request.stubs(:environment).returns(Environment.default) |
| 233 | 233 | request.identifier = 'testid' |
| 234 | 234 | request.valid? |
| 235 | - assert !request.errors.invalid?(:identifier) | |
| 235 | + assert !request.errors[:identifier.to_s].present? | |
| 236 | 236 | |
| 237 | 237 | Organization.create!(:name => 'test', :identifier => 'testid') |
| 238 | 238 | request.valid? |
| 239 | - assert request.errors.invalid?(:identifier) | |
| 239 | + assert request.errors[:identifier.to_s].present? | |
| 240 | 240 | end |
| 241 | 241 | |
| 242 | 242 | should 'require the same fields as an enterprise does' do | ... | ... |
test/unit/domain_test.rb
| ... | ... | @@ -10,37 +10,37 @@ class DomainTest < ActiveSupport::TestCase |
| 10 | 10 | should 'not allow domains without name' do |
| 11 | 11 | domain = Domain.new |
| 12 | 12 | domain.valid? |
| 13 | - assert domain.errors.invalid?(:name) | |
| 13 | + assert domain.errors[:name.to_s].present? | |
| 14 | 14 | end |
| 15 | 15 | |
| 16 | 16 | should 'not allow domain without dot' do |
| 17 | 17 | domain = Domain.new(:name => 'test') |
| 18 | 18 | domain.valid? |
| 19 | - assert domain.errors.invalid?(:name) | |
| 19 | + assert domain.errors[:name.to_s].present? | |
| 20 | 20 | end |
| 21 | 21 | |
| 22 | 22 | should 'allow domains with dot' do |
| 23 | 23 | domain = Domain.new(:name => 'test.org') |
| 24 | 24 | domain.valid? |
| 25 | - assert !domain.errors.invalid?(:name) | |
| 25 | + assert !domain.errors[:name.to_s].present? | |
| 26 | 26 | end |
| 27 | 27 | |
| 28 | 28 | should 'not allow domains with upper cased letters' do |
| 29 | 29 | domain = Domain.new(:name => 'tEst.org') |
| 30 | 30 | domain.valid? |
| 31 | - assert domain.errors.invalid?(:name) | |
| 31 | + assert domain.errors[:name.to_s].present? | |
| 32 | 32 | end |
| 33 | 33 | |
| 34 | 34 | should 'allow domains with hyphen' do |
| 35 | 35 | domain = Domain.new(:name => 'test-domain.org') |
| 36 | 36 | domain.valid? |
| 37 | - assert !domain.errors.invalid?(:name) | |
| 37 | + assert !domain.errors[:name.to_s].present? | |
| 38 | 38 | end |
| 39 | 39 | |
| 40 | 40 | should 'allow domains with underscore' do |
| 41 | 41 | domain = Domain.new(:name => 'test_domain.org') |
| 42 | 42 | domain.valid? |
| 43 | - assert !domain.errors.invalid?(:name) | |
| 43 | + assert !domain.errors[:name.to_s].present? | |
| 44 | 44 | end |
| 45 | 45 | |
| 46 | 46 | def test_owner |
| ... | ... | @@ -59,11 +59,11 @@ class DomainTest < ActiveSupport::TestCase |
| 59 | 59 | d = Domain.new |
| 60 | 60 | d.name = 'www.example.net' |
| 61 | 61 | d.valid? |
| 62 | - assert d.errors.invalid?(:name) | |
| 62 | + assert d.errors[:name.to_s].present? | |
| 63 | 63 | |
| 64 | 64 | d.name = 'example.net' |
| 65 | 65 | d.valid? |
| 66 | - assert !d.errors.invalid?(:name) | |
| 66 | + assert !d.errors[:name.to_s].present? | |
| 67 | 67 | end |
| 68 | 68 | |
| 69 | 69 | def test_find_by_name |
| ... | ... | @@ -82,7 +82,7 @@ class DomainTest < ActiveSupport::TestCase |
| 82 | 82 | |
| 83 | 83 | d = Domain.new(:name => 'example.net') |
| 84 | 84 | assert !d.valid? |
| 85 | - assert d.errors.invalid?(:name) | |
| 85 | + assert d.errors[:name.to_s].present? | |
| 86 | 86 | end |
| 87 | 87 | |
| 88 | 88 | def test_environment | ... | ... |
test/unit/enterprise_test.rb
| ... | ... | @@ -12,27 +12,27 @@ class EnterpriseTest < ActiveSupport::TestCase |
| 12 | 12 | def test_identifier_validation |
| 13 | 13 | p = Enterprise.new |
| 14 | 14 | p.valid? |
| 15 | - assert p.errors.invalid?(:identifier) | |
| 15 | + assert p.errors[:identifier.to_s].present? | |
| 16 | 16 | |
| 17 | 17 | p.identifier = 'with space' |
| 18 | 18 | p.valid? |
| 19 | - assert p.errors.invalid?(:identifier) | |
| 19 | + assert p.errors[:identifier.to_s].present? | |
| 20 | 20 | |
| 21 | 21 | p.identifier = 'áéíóú' |
| 22 | 22 | p.valid? |
| 23 | - assert p.errors.invalid?(:identifier) | |
| 23 | + assert p.errors[:identifier.to_s].present? | |
| 24 | 24 | |
| 25 | 25 | p.identifier = 'rightformat2007' |
| 26 | 26 | p.valid? |
| 27 | - assert ! p.errors.invalid?(:identifier) | |
| 27 | + assert ! p.errors[:identifier.to_s].present? | |
| 28 | 28 | |
| 29 | 29 | p.identifier = 'rightformat' |
| 30 | 30 | p.valid? |
| 31 | - assert ! p.errors.invalid?(:identifier) | |
| 31 | + assert ! p.errors[:identifier.to_s].present? | |
| 32 | 32 | |
| 33 | 33 | p.identifier = 'right_format' |
| 34 | 34 | p.valid? |
| 35 | - assert ! p.errors.invalid?(:identifier) | |
| 35 | + assert ! p.errors[:identifier.to_s].present? | |
| 36 | 36 | end |
| 37 | 37 | |
| 38 | 38 | def test_has_domains |
| ... | ... | @@ -300,11 +300,11 @@ class EnterpriseTest < ActiveSupport::TestCase |
| 300 | 300 | e.expects(:required_enterprise_fields).returns(['contact_phone']).at_least_once |
| 301 | 301 | enterprise = Enterprise.new(:environment => e) |
| 302 | 302 | assert ! enterprise.valid? |
| 303 | - assert enterprise.errors.invalid?(:contact_phone) | |
| 303 | + assert enterprise.errors[:contact_phone.to_s].present? | |
| 304 | 304 | |
| 305 | 305 | enterprise.contact_phone = '99999' |
| 306 | 306 | enterprise.valid? |
| 307 | - assert ! enterprise.errors.invalid?(:contact_phone) | |
| 307 | + assert ! enterprise.errors[:contact_phone.to_s].present? | |
| 308 | 308 | end |
| 309 | 309 | |
| 310 | 310 | should 'enable contact' do | ... | ... |
test/unit/environment_test.rb
| ... | ... | @@ -12,7 +12,7 @@ class EnvironmentTest < ActiveSupport::TestCase |
| 12 | 12 | vc2 = Environment.new(:name => 'Another Test Community') |
| 13 | 13 | vc2.is_default = true |
| 14 | 14 | assert !vc2.valid? |
| 15 | - assert vc2.errors.invalid?(:is_default) | |
| 15 | + assert vc2.errors[:is_default.to_s].present? | |
| 16 | 16 | |
| 17 | 17 | assert_equal vc, Environment.default |
| 18 | 18 | end |
| ... | ... | @@ -56,10 +56,10 @@ class EnvironmentTest < ActiveSupport::TestCase |
| 56 | 56 | def test_name_is_mandatory |
| 57 | 57 | v = Environment.new |
| 58 | 58 | v.valid? |
| 59 | - assert v.errors.invalid?(:name) | |
| 59 | + assert v.errors[:name.to_s].present? | |
| 60 | 60 | v.name = 'blablabla' |
| 61 | 61 | v.valid? |
| 62 | - assert !v.errors.invalid?(:name) | |
| 62 | + assert !v.errors[:name.to_s].present? | |
| 63 | 63 | end |
| 64 | 64 | |
| 65 | 65 | def test_terms_of_use |
| ... | ... | @@ -181,11 +181,11 @@ class EnvironmentTest < ActiveSupport::TestCase |
| 181 | 181 | |
| 182 | 182 | env.contact_email = 'test' |
| 183 | 183 | env.valid? |
| 184 | - assert env.errors.invalid?(:contact_email) | |
| 184 | + assert env.errors[:contact_email.to_s].present? | |
| 185 | 185 | |
| 186 | 186 | env.contact_email = 'test@example.com' |
| 187 | 187 | env.valid? |
| 188 | - assert !env.errors.invalid?(:contact_email) | |
| 188 | + assert !env.errors[:contact_email.to_s].present? | |
| 189 | 189 | end |
| 190 | 190 | |
| 191 | 191 | should 'provide a default hostname' do |
| ... | ... | @@ -1155,19 +1155,19 @@ class EnvironmentTest < ActiveSupport::TestCase |
| 1155 | 1155 | |
| 1156 | 1156 | environment.reports_lower_bound = nil |
| 1157 | 1157 | environment.valid? |
| 1158 | - assert environment.errors.invalid?(:reports_lower_bound) | |
| 1158 | + assert environment.errors[:reports_lower_bound.to_s].present? | |
| 1159 | 1159 | |
| 1160 | 1160 | environment.reports_lower_bound = -3 |
| 1161 | 1161 | environment.valid? |
| 1162 | - assert environment.errors.invalid?(:reports_lower_bound) | |
| 1162 | + assert environment.errors[:reports_lower_bound.to_s].present? | |
| 1163 | 1163 | |
| 1164 | 1164 | environment.reports_lower_bound = 1.5 |
| 1165 | 1165 | environment.valid? |
| 1166 | - assert environment.errors.invalid?(:reports_lower_bound) | |
| 1166 | + assert environment.errors[:reports_lower_bound.to_s].present? | |
| 1167 | 1167 | |
| 1168 | 1168 | environment.reports_lower_bound = 5 |
| 1169 | 1169 | environment.valid? |
| 1170 | - assert !environment.errors.invalid?(:reports_lower_bound) | |
| 1170 | + assert !environment.errors[:reports_lower_bound.to_s].present? | |
| 1171 | 1171 | end |
| 1172 | 1172 | |
| 1173 | 1173 | should 'be able to enable or disable a plugin with the class or class name' do |
| ... | ... | @@ -1214,12 +1214,12 @@ class EnvironmentTest < ActiveSupport::TestCase |
| 1214 | 1214 | environment = fast_create(Environment) |
| 1215 | 1215 | environment.redirection_after_login = 'invalid_option' |
| 1216 | 1216 | environment.save |
| 1217 | - assert environment.errors.invalid?(:redirection_after_login) | |
| 1217 | + assert environment.errors[:redirection_after_login.to_s].present? | |
| 1218 | 1218 | |
| 1219 | 1219 | Environment.login_redirection_options.keys.each do |redirection| |
| 1220 | 1220 | environment.redirection_after_login = redirection |
| 1221 | 1221 | environment.save |
| 1222 | - assert !environment.errors.invalid?(:redirection_after_login) | |
| 1222 | + assert !environment.errors[:redirection_after_login.to_s].present? | |
| 1223 | 1223 | end |
| 1224 | 1224 | end |
| 1225 | 1225 | |
| ... | ... | @@ -1306,11 +1306,11 @@ class EnvironmentTest < ActiveSupport::TestCase |
| 1306 | 1306 | environment.stubs(:available_locales).returns(['en']) |
| 1307 | 1307 | environment.default_language = 'pt' |
| 1308 | 1308 | environment.valid? |
| 1309 | - assert environment.errors.invalid?(:default_language) | |
| 1309 | + assert environment.errors[:default_language.to_s].present? | |
| 1310 | 1310 | |
| 1311 | 1311 | environment.default_language = 'en' |
| 1312 | 1312 | environment.valid? |
| 1313 | - assert !environment.errors.invalid?(:default_language) | |
| 1313 | + assert !environment.errors[:default_language.to_s].present? | |
| 1314 | 1314 | end |
| 1315 | 1315 | |
| 1316 | 1316 | should 'define default locale or use the config default locale' do |
| ... | ... | @@ -1329,11 +1329,11 @@ class EnvironmentTest < ActiveSupport::TestCase |
| 1329 | 1329 | |
| 1330 | 1330 | environment.languages = ['zz'] |
| 1331 | 1331 | environment.valid? |
| 1332 | - assert environment.errors.invalid?(:languages) | |
| 1332 | + assert environment.errors[:languages.to_s].present? | |
| 1333 | 1333 | |
| 1334 | 1334 | environment.languages = ['en'] |
| 1335 | 1335 | environment.valid? |
| 1336 | - assert !environment.errors.invalid?(:languages) | |
| 1336 | + assert !environment.errors[:languages.to_s].present? | |
| 1337 | 1337 | end |
| 1338 | 1338 | |
| 1339 | 1339 | should 'define locales or use the config locales' do | ... | ... |
test/unit/event_test.rb
| ... | ... | @@ -44,10 +44,10 @@ class EventTest < ActiveSupport::TestCase |
| 44 | 44 | e = Event.new |
| 45 | 45 | e.start_date = nil |
| 46 | 46 | e.valid? |
| 47 | - assert e.errors.invalid?(:start_date) | |
| 47 | + assert e.errors[:start_date.to_s].present? | |
| 48 | 48 | e.start_date = Date.today |
| 49 | 49 | e.valid? |
| 50 | - assert !e.errors.invalid?(:start_date) | |
| 50 | + assert !e.errors[:start_date.to_s].present? | |
| 51 | 51 | end |
| 52 | 52 | |
| 53 | 53 | should 'have a end date' do |
| ... | ... | @@ -63,11 +63,11 @@ class EventTest < ActiveSupport::TestCase |
| 63 | 63 | should 'not allow end date before start date' do |
| 64 | 64 | e = Event.new(:start_date => Date.new(2008, 01, 01), :end_date => Date.new(2007,01,01)) |
| 65 | 65 | e.valid? |
| 66 | - assert e.errors.invalid?(:start_date) | |
| 66 | + assert e.errors[:start_date.to_s].present? | |
| 67 | 67 | |
| 68 | 68 | e.end_date = Date.new(2008,01,05) |
| 69 | 69 | e.valid? |
| 70 | - assert !e.errors.invalid?(:start_date) | |
| 70 | + assert !e.errors[:start_date.to_s].present? | |
| 71 | 71 | end |
| 72 | 72 | |
| 73 | 73 | should 'find by range of dates' do | ... | ... |
test/unit/input_test.rb
| ... | ... | @@ -7,11 +7,11 @@ class InputTest < ActiveSupport::TestCase |
| 7 | 7 | |
| 8 | 8 | input = Input.new |
| 9 | 9 | input.valid? |
| 10 | - assert input.errors.invalid?(:product_category) | |
| 10 | + assert input.errors[:product_category.to_s].present? | |
| 11 | 11 | |
| 12 | 12 | input.product_category = product_category |
| 13 | 13 | input.valid? |
| 14 | - assert !input.errors.invalid?(:product_category) | |
| 14 | + assert !input.errors[:product_category.to_s].present? | |
| 15 | 15 | end |
| 16 | 16 | |
| 17 | 17 | should 'require product' do |
| ... | ... | @@ -20,11 +20,11 @@ class InputTest < ActiveSupport::TestCase |
| 20 | 20 | |
| 21 | 21 | input = Input.new |
| 22 | 22 | input.valid? |
| 23 | - assert input.errors.invalid?(:product) | |
| 23 | + assert input.errors[:product.to_s].present? | |
| 24 | 24 | |
| 25 | 25 | input.product = product |
| 26 | 26 | input.valid? |
| 27 | - assert !input.errors.invalid?(:product) | |
| 27 | + assert !input.errors[:product.to_s].present? | |
| 28 | 28 | end |
| 29 | 29 | |
| 30 | 30 | should 'store inputs ordered by position' do | ... | ... |
test/unit/invite_friend_test.rb
| ... | ... | @@ -27,54 +27,54 @@ class InviteFriendTest < ActiveSupport::TestCase |
| 27 | 27 | task = InviteFriend.new |
| 28 | 28 | task.valid? |
| 29 | 29 | |
| 30 | - ok('must not validate with empty requestor') { task.errors.invalid?(:requestor_id) } | |
| 30 | + ok('must not validate with empty requestor') { task.errors[:requestor_id.to_s].present? } | |
| 31 | 31 | |
| 32 | 32 | task.requestor = create_user('testuser2').person |
| 33 | 33 | task.valid? |
| 34 | - ok('must validate when requestor is given') { !task.errors.invalid?(:requestor_id)} | |
| 34 | + ok('must validate when requestor is given') { !task.errors[:requestor_id.to_s].present?} | |
| 35 | 35 | end |
| 36 | 36 | |
| 37 | 37 | should 'require friend email if no target given (person being invited)' do |
| 38 | 38 | task = InviteFriend.new |
| 39 | 39 | task.valid? |
| 40 | 40 | |
| 41 | - ok('must not validate with empty target email') { task.errors.invalid?(:friend_email) } | |
| 41 | + ok('must not validate with empty target email') { task.errors[:friend_email.to_s].present? } | |
| 42 | 42 | |
| 43 | 43 | task.friend_email = 'test@test.com' |
| 44 | 44 | task.valid? |
| 45 | - ok('must validate when target email is given') { !task.errors.invalid?(:friend_email)} | |
| 45 | + ok('must validate when target email is given') { !task.errors[:friend_email.to_s].present?} | |
| 46 | 46 | end |
| 47 | 47 | |
| 48 | 48 | should 'dont require friend email if target given (person being invited)' do |
| 49 | 49 | task = InviteFriend.new(:target => create_user('testuser2').person) |
| 50 | 50 | task.valid? |
| 51 | 51 | |
| 52 | - ok('must validate with empty target email') { !task.errors.invalid?(:friend_email) } | |
| 52 | + ok('must validate with empty target email') { !task.errors[:friend_email.to_s].present? } | |
| 53 | 53 | end |
| 54 | 54 | |
| 55 | 55 | should 'require target (person being invited) if no friend email given' do |
| 56 | 56 | task = InviteFriend.new |
| 57 | 57 | task.valid? |
| 58 | 58 | |
| 59 | - ok('must not validate with no target') { task.errors.invalid?(:target_id) } | |
| 59 | + ok('must not validate with no target') { task.errors[:target_id.to_s].present? } | |
| 60 | 60 | |
| 61 | 61 | task.target = create_user('testuser2').person |
| 62 | 62 | task.valid? |
| 63 | - ok('must validate when target is given') { !task.errors.invalid?(:target_id)} | |
| 63 | + ok('must validate when target is given') { !task.errors[:target_id.to_s].present?} | |
| 64 | 64 | end |
| 65 | 65 | |
| 66 | 66 | should 'dont require target (person being invited) if friend email given' do |
| 67 | 67 | task = InviteFriend.new(:friend_email => "test@test.com") |
| 68 | 68 | task.valid? |
| 69 | 69 | |
| 70 | - ok('must validate with no target') { !task.errors.invalid?(:target_id) } | |
| 70 | + ok('must validate with no target') { !task.errors[:target_id.to_s].present? } | |
| 71 | 71 | end |
| 72 | 72 | |
| 73 | 73 | should 'dont require message if target given (person being invited)' do |
| 74 | 74 | task = InviteFriend.new(:target => create_user('testuser2').person) |
| 75 | 75 | task.valid? |
| 76 | 76 | |
| 77 | - ok('must validate with no target') { !task.errors.invalid?(:message) } | |
| 77 | + ok('must validate with no target') { !task.errors[:message.to_s].present? } | |
| 78 | 78 | end |
| 79 | 79 | |
| 80 | 80 | should 'not send e-mails to requestor' do | ... | ... |
test/unit/invite_member_test.rb
| ... | ... | @@ -26,35 +26,35 @@ class InviteMemberTest < ActiveSupport::TestCase |
| 26 | 26 | task = InviteMember.new |
| 27 | 27 | task.valid? |
| 28 | 28 | |
| 29 | - ok('community is required') { task.errors.invalid?(:community_id) } | |
| 29 | + ok('community is required') { task.errors[:community_id.to_s].present? } | |
| 30 | 30 | end |
| 31 | 31 | |
| 32 | 32 | should 'require friend email if no target given (person being invited)' do |
| 33 | 33 | task = InviteMember.new |
| 34 | 34 | task.valid? |
| 35 | 35 | |
| 36 | - ok('friend_email is required') { task.errors.invalid?(:friend_email) } | |
| 36 | + ok('friend_email is required') { task.errors[:friend_email.to_s].present? } | |
| 37 | 37 | end |
| 38 | 38 | |
| 39 | 39 | should 'dont require friend email if target given (person being invited)' do |
| 40 | 40 | task = InviteMember.new(:target => create_user('testuser2').person) |
| 41 | 41 | task.valid? |
| 42 | 42 | |
| 43 | - ok('friend_email isnt required') { !task.errors.invalid?(:friend_email) } | |
| 43 | + ok('friend_email isnt required') { !task.errors[:friend_email.to_s].present? } | |
| 44 | 44 | end |
| 45 | 45 | |
| 46 | 46 | should 'require target (person being invited) if no friend email given' do |
| 47 | 47 | task = InviteMember.new |
| 48 | 48 | task.valid? |
| 49 | 49 | |
| 50 | - ok('target is required') { task.errors.invalid?(:target_id) } | |
| 50 | + ok('target is required') { task.errors[:target_id.to_s].present? } | |
| 51 | 51 | end |
| 52 | 52 | |
| 53 | 53 | should 'dont require target (person being invited) if friend email given' do |
| 54 | 54 | task = InviteMember.new(:friend_email => "test@test.com") |
| 55 | 55 | task.valid? |
| 56 | 56 | |
| 57 | - ok('target isn required') { !task.errors.invalid?(:target_id) } | |
| 57 | + ok('target isn required') { !task.errors[:target_id.to_s].present? } | |
| 58 | 58 | end |
| 59 | 59 | |
| 60 | 60 | should 'not send e-mails to requestor' do | ... | ... |
test/unit/mailing_test.rb
| ... | ... | @@ -23,31 +23,31 @@ class MailingTest < ActiveSupport::TestCase |
| 23 | 23 | should 'require source_id' do |
| 24 | 24 | mailing = Mailing.new |
| 25 | 25 | mailing.valid? |
| 26 | - assert mailing.errors.invalid?(:source_id) | |
| 26 | + assert mailing.errors[:source_id.to_s].present? | |
| 27 | 27 | |
| 28 | 28 | mailing.source_id = Environment.default.id |
| 29 | 29 | mailing.valid? |
| 30 | - assert !mailing.errors.invalid?(:source_id) | |
| 30 | + assert !mailing.errors[:source_id.to_s].present? | |
| 31 | 31 | end |
| 32 | 32 | |
| 33 | 33 | should 'require subject' do |
| 34 | 34 | mailing = Mailing.new |
| 35 | 35 | mailing.valid? |
| 36 | - assert mailing.errors.invalid?(:subject) | |
| 36 | + assert mailing.errors[:subject.to_s].present? | |
| 37 | 37 | |
| 38 | 38 | mailing.subject = 'Hello :)' |
| 39 | 39 | mailing.valid? |
| 40 | - assert !mailing.errors.invalid?(:subject) | |
| 40 | + assert !mailing.errors[:subject.to_s].present? | |
| 41 | 41 | end |
| 42 | 42 | |
| 43 | 43 | should 'require body' do |
| 44 | 44 | mailing = Mailing.new |
| 45 | 45 | mailing.valid? |
| 46 | - assert mailing.errors.invalid?(:body) | |
| 46 | + assert mailing.errors[:body.to_s].present? | |
| 47 | 47 | |
| 48 | 48 | mailing.body = 'We have some news!' |
| 49 | 49 | mailing.valid? |
| 50 | - assert !mailing.errors.invalid?(:body) | |
| 50 | + assert !mailing.errors[:body.to_s].present? | |
| 51 | 51 | end |
| 52 | 52 | |
| 53 | 53 | should 'return source' do | ... | ... |
test/unit/organization_mailing_test.rb
| ... | ... | @@ -18,11 +18,11 @@ class OrganizationMailingTest < ActiveSupport::TestCase |
| 18 | 18 | should 'require source_id' do |
| 19 | 19 | mailing = OrganizationMailing.new |
| 20 | 20 | mailing.valid? |
| 21 | - assert mailing.errors.invalid?(:source_id) | |
| 21 | + assert mailing.errors[:source_id.to_s].present? | |
| 22 | 22 | |
| 23 | 23 | mailing.source_id = community.id |
| 24 | 24 | mailing.valid? |
| 25 | - assert !mailing.errors.invalid?(:source_id) | |
| 25 | + assert !mailing.errors[:source_id.to_s].present? | |
| 26 | 26 | end |
| 27 | 27 | |
| 28 | 28 | should 'return community name' do | ... | ... |
test/unit/organization_test.rb
| ... | ... | @@ -80,20 +80,20 @@ class OrganizationTest < ActiveSupport::TestCase |
| 80 | 80 | should 'validate contact_email if filled' do |
| 81 | 81 | org = Organization.new |
| 82 | 82 | org.valid? |
| 83 | - assert !org.errors.invalid?(:contact_email) | |
| 83 | + assert !org.errors[:contact_email.to_s].present? | |
| 84 | 84 | |
| 85 | 85 | org.contact_email = '' |
| 86 | 86 | org.valid? |
| 87 | - assert !org.errors.invalid?(:contact_email) | |
| 87 | + assert !org.errors[:contact_email.to_s].present? | |
| 88 | 88 | |
| 89 | 89 | |
| 90 | 90 | org.contact_email = 'invalid-email' |
| 91 | 91 | org.valid? |
| 92 | - assert org.errors.invalid?(:contact_email) | |
| 92 | + assert org.errors[:contact_email.to_s].present? | |
| 93 | 93 | |
| 94 | 94 | org.contact_email = 'someone@somedomain.com' |
| 95 | 95 | org.valid? |
| 96 | - assert !org.errors.invalid?(:contact_email) | |
| 96 | + assert !org.errors[:contact_email.to_s].present? | |
| 97 | 97 | end |
| 98 | 98 | |
| 99 | 99 | should 'list contact_email plus admin emails as "notification emails"' do |
| ... | ... | @@ -183,15 +183,15 @@ class OrganizationTest < ActiveSupport::TestCase |
| 183 | 183 | org = Organization.new |
| 184 | 184 | org.foundation_year = 'xxxx' |
| 185 | 185 | org.valid? |
| 186 | - assert org.errors.invalid?(:foundation_year) | |
| 186 | + assert org.errors[:foundation_year.to_s].present? | |
| 187 | 187 | |
| 188 | 188 | org.foundation_year = 20.07 |
| 189 | 189 | org.valid? |
| 190 | - assert org.errors.invalid?(:foundation_year) | |
| 190 | + assert org.errors[:foundation_year.to_s].present? | |
| 191 | 191 | |
| 192 | 192 | org.foundation_year = 2007 |
| 193 | 193 | org.valid? |
| 194 | - assert ! org.errors.invalid?(:foundation_year) | |
| 194 | + assert ! org.errors[:foundation_year.to_s].present? | |
| 195 | 195 | end |
| 196 | 196 | |
| 197 | 197 | should 'has closed' do |
| ... | ... | @@ -393,11 +393,11 @@ class OrganizationTest < ActiveSupport::TestCase |
| 393 | 393 | should 'validates format of cnpj' do |
| 394 | 394 | organization = Organization.new(:cnpj => '239-234.234') |
| 395 | 395 | organization.valid? |
| 396 | - assert organization.errors.invalid?(:cnpj) | |
| 396 | + assert organization.errors[:cnpj.to_s].present? | |
| 397 | 397 | |
| 398 | 398 | organization.cnpj = '94.132.024/0001-48' |
| 399 | 399 | organization.valid? |
| 400 | - assert !organization.errors.invalid?(:cnpj) | |
| 400 | + assert !organization.errors[:cnpj.to_s].present? | |
| 401 | 401 | end |
| 402 | 402 | |
| 403 | 403 | should 'return members by role in a json format' do | ... | ... |
test/unit/person_test.rb
| ... | ... | @@ -60,7 +60,7 @@ class PersonTest < ActiveSupport::TestCase |
| 60 | 60 | p2 = Person.new(:environment => Environment.default) |
| 61 | 61 | p2.user = u |
| 62 | 62 | assert !p2.valid? |
| 63 | - assert p2.errors.invalid?(:user_id) | |
| 63 | + assert p2.errors[:user_id.to_s].present? | |
| 64 | 64 | end |
| 65 | 65 | |
| 66 | 66 | should "have person info fields" do |
| ... | ... | @@ -133,7 +133,7 @@ class PersonTest < ActiveSupport::TestCase |
| 133 | 133 | other = create_user('seconduser', :email => 'other@domain.com').person |
| 134 | 134 | other.email = 'user@domain.com' |
| 135 | 135 | other.valid? |
| 136 | - assert other.errors.invalid?(:email) | |
| 136 | + assert other.errors[:email.to_s].present? | |
| 137 | 137 | assert_no_match /\{fn\}/, other.errors.on(:email) |
| 138 | 138 | end |
| 139 | 139 | |
| ... | ... | @@ -144,7 +144,7 @@ class PersonTest < ActiveSupport::TestCase |
| 144 | 144 | other = create_user('user', :email => 'other@example.com', :environment => other_env).person |
| 145 | 145 | other.email = 'user@example.com' |
| 146 | 146 | other.valid? |
| 147 | - assert !other.errors.invalid?(:email) | |
| 147 | + assert !other.errors[:email.to_s].present? | |
| 148 | 148 | end |
| 149 | 149 | |
| 150 | 150 | should 'be an admin if have permission of environment administration' do |
| ... | ... | @@ -318,7 +318,7 @@ class PersonTest < ActiveSupport::TestCase |
| 318 | 318 | should 'required name' do |
| 319 | 319 | person = Person.new(:environment => Environment.default) |
| 320 | 320 | assert !person.valid? |
| 321 | - assert person.errors.invalid?(:name) | |
| 321 | + assert person.errors[:name.to_s].present? | |
| 322 | 322 | end |
| 323 | 323 | |
| 324 | 324 | should 'already request friendship' do |
| ... | ... | @@ -463,11 +463,11 @@ class PersonTest < ActiveSupport::TestCase |
| 463 | 463 | e.expects(:required_person_fields).returns(['cell_phone']).at_least_once |
| 464 | 464 | person = Person.new(:environment => e) |
| 465 | 465 | assert ! person.valid? |
| 466 | - assert person.errors.invalid?(:cell_phone) | |
| 466 | + assert person.errors[:cell_phone.to_s].present? | |
| 467 | 467 | |
| 468 | 468 | person.cell_phone = '99999' |
| 469 | 469 | person.valid? |
| 470 | - assert ! person.errors.invalid?(:cell_phone) | |
| 470 | + assert ! person.errors[:cell_phone.to_s].present? | |
| 471 | 471 | end |
| 472 | 472 | |
| 473 | 473 | should 'require custom_area_of_study if area_of_study is others' do |
| ... | ... | @@ -476,11 +476,11 @@ class PersonTest < ActiveSupport::TestCase |
| 476 | 476 | |
| 477 | 477 | person = Person.new(:environment => e, :area_of_study => 'Others') |
| 478 | 478 | assert !person.valid? |
| 479 | - assert person.errors.invalid?(:custom_area_of_study) | |
| 479 | + assert person.errors[:custom_area_of_study.to_s].present? | |
| 480 | 480 | |
| 481 | 481 | person.custom_area_of_study = 'Customized area of study' |
| 482 | 482 | person.valid? |
| 483 | - assert ! person.errors.invalid?(:custom_area_of_study) | |
| 483 | + assert ! person.errors[:custom_area_of_study.to_s].present? | |
| 484 | 484 | end |
| 485 | 485 | |
| 486 | 486 | should 'not require custom_area_of_study if area_of_study is not others' do |
| ... | ... | @@ -489,7 +489,7 @@ class PersonTest < ActiveSupport::TestCase |
| 489 | 489 | |
| 490 | 490 | person = Person.new(:environment => e, :area_of_study => 'Agrometeorology') |
| 491 | 491 | person.valid? |
| 492 | - assert ! person.errors.invalid?(:custom_area_of_study) | |
| 492 | + assert ! person.errors[:custom_area_of_study.to_s].present? | |
| 493 | 493 | end |
| 494 | 494 | |
| 495 | 495 | should 'require custom_formation if formation is others' do |
| ... | ... | @@ -498,11 +498,11 @@ class PersonTest < ActiveSupport::TestCase |
| 498 | 498 | |
| 499 | 499 | person = Person.new(:environment => e, :formation => 'Others') |
| 500 | 500 | assert !person.valid? |
| 501 | - assert person.errors.invalid?(:custom_formation) | |
| 501 | + assert person.errors[:custom_formation.to_s].present? | |
| 502 | 502 | |
| 503 | 503 | person.custom_formation = 'Customized formation' |
| 504 | 504 | person.valid? |
| 505 | - assert ! person.errors.invalid?(:custom_formation) | |
| 505 | + assert ! person.errors[:custom_formation.to_s].present? | |
| 506 | 506 | end |
| 507 | 507 | |
| 508 | 508 | should 'not require custom_formation if formation is not others' do |
| ... | ... | @@ -511,7 +511,7 @@ class PersonTest < ActiveSupport::TestCase |
| 511 | 511 | |
| 512 | 512 | person = Person.new(:environment => e, :formation => 'Agrometeorology') |
| 513 | 513 | assert !person.valid? |
| 514 | - assert ! person.errors.invalid?(:custom_formation) | |
| 514 | + assert ! person.errors[:custom_formation.to_s].present? | |
| 515 | 515 | end |
| 516 | 516 | |
| 517 | 517 | should 'identify when person is a friend' do |
| ... | ... | @@ -1175,7 +1175,7 @@ class PersonTest < ActiveSupport::TestCase |
| 1175 | 1175 | should 'not accept an empty year on birth date' do |
| 1176 | 1176 | p = Person.new({"birth_date(2i)"=>"11", "birth_date(3i)"=>"15", "birth_date(1i)"=>""}) |
| 1177 | 1177 | p.valid? |
| 1178 | - assert p.errors.invalid?(:birth_date) | |
| 1178 | + assert p.errors[:birth_date.to_s].present? | |
| 1179 | 1179 | end |
| 1180 | 1180 | |
| 1181 | 1181 | should 'associate report with the correct complaint' do | ... | ... |
test/unit/product_test.rb
| ... | ... | @@ -205,7 +205,7 @@ class ProductTest < ActiveSupport::TestCase |
| 205 | 205 | should 'not save without category' do |
| 206 | 206 | product = Product.new(:name => 'A product without category') |
| 207 | 207 | product.valid? |
| 208 | - assert product.errors.invalid?(:product_category_id) | |
| 208 | + assert product.errors[:product_category_id.to_s].present? | |
| 209 | 209 | end |
| 210 | 210 | |
| 211 | 211 | should 'not save with a invalid category' do | ... | ... |
test/unit/production_cost_test.rb
| ... | ... | @@ -5,11 +5,11 @@ class ProductionCostTest < ActiveSupport::TestCase |
| 5 | 5 | should 'have name' do |
| 6 | 6 | p = ProductionCost.new |
| 7 | 7 | p.valid? |
| 8 | - assert p.errors.invalid?(:name) | |
| 8 | + assert p.errors[:name.to_s].present? | |
| 9 | 9 | |
| 10 | 10 | p.name = 'Taxes' |
| 11 | 11 | p.valid? |
| 12 | - assert !p.errors.invalid?(:name) | |
| 12 | + assert !p.errors[:name.to_s].present? | |
| 13 | 13 | end |
| 14 | 14 | |
| 15 | 15 | should 'not validates name if it is blank' do |
| ... | ... | @@ -24,11 +24,11 @@ class ProductionCostTest < ActiveSupport::TestCase |
| 24 | 24 | |
| 25 | 25 | p.name = 'a'*40 |
| 26 | 26 | p.valid? |
| 27 | - assert p.errors.invalid?(:name) | |
| 27 | + assert p.errors[:name.to_s].present? | |
| 28 | 28 | |
| 29 | 29 | p.name = 'a'*30 |
| 30 | 30 | p.valid? |
| 31 | - assert !p.errors.invalid?(:name) | |
| 31 | + assert !p.errors[:name.to_s].present? | |
| 32 | 32 | end |
| 33 | 33 | |
| 34 | 34 | should 'not have duplicated name on same environment' do |
| ... | ... | @@ -37,7 +37,7 @@ class ProductionCostTest < ActiveSupport::TestCase |
| 37 | 37 | invalid_cost = ProductionCost.new(:name => 'Taxes', :owner => Environment.default) |
| 38 | 38 | invalid_cost.valid? |
| 39 | 39 | |
| 40 | - assert invalid_cost.errors.invalid?(:name) | |
| 40 | + assert invalid_cost.errors[:name.to_s].present? | |
| 41 | 41 | end |
| 42 | 42 | |
| 43 | 43 | should 'not have duplicated name on same enterprise' do |
| ... | ... | @@ -47,7 +47,7 @@ class ProductionCostTest < ActiveSupport::TestCase |
| 47 | 47 | invalid_cost = ProductionCost.new(:name => 'Taxes', :owner => enterprise) |
| 48 | 48 | invalid_cost.valid? |
| 49 | 49 | |
| 50 | - assert invalid_cost.errors.invalid?(:name) | |
| 50 | + assert invalid_cost.errors[:name.to_s].present? | |
| 51 | 51 | end |
| 52 | 52 | |
| 53 | 53 | should 'not allow same name on enterprise if already has on environment' do |
| ... | ... | @@ -58,7 +58,7 @@ class ProductionCostTest < ActiveSupport::TestCase |
| 58 | 58 | |
| 59 | 59 | cost2.valid? |
| 60 | 60 | |
| 61 | - assert !cost2.errors.invalid?(:name) | |
| 61 | + assert !cost2.errors[:name.to_s].present? | |
| 62 | 62 | end |
| 63 | 63 | |
| 64 | 64 | should 'allow duplicated name on different enterprises' do |
| ... | ... | @@ -70,28 +70,28 @@ class ProductionCostTest < ActiveSupport::TestCase |
| 70 | 70 | |
| 71 | 71 | cost2.valid? |
| 72 | 72 | |
| 73 | - assert !cost2.errors.invalid?(:name) | |
| 73 | + assert !cost2.errors[:name.to_s].present? | |
| 74 | 74 | end |
| 75 | 75 | |
| 76 | 76 | should 'be associated to an environment as owner' do |
| 77 | 77 | p = ProductionCost.new |
| 78 | 78 | p.valid? |
| 79 | - assert p.errors.invalid?(:owner) | |
| 79 | + assert p.errors[:owner.to_s].present? | |
| 80 | 80 | |
| 81 | 81 | p.owner = Environment.default |
| 82 | 82 | p.valid? |
| 83 | - assert !p.errors.invalid?(:owner) | |
| 83 | + assert !p.errors[:owner.to_s].present? | |
| 84 | 84 | end |
| 85 | 85 | |
| 86 | 86 | should 'be associated to an enterprise as owner' do |
| 87 | 87 | enterprise = fast_create(Enterprise) |
| 88 | 88 | p = ProductionCost.new |
| 89 | 89 | p.valid? |
| 90 | - assert p.errors.invalid?(:owner) | |
| 90 | + assert p.errors[:owner.to_s].present? | |
| 91 | 91 | |
| 92 | 92 | p.owner = enterprise |
| 93 | 93 | p.valid? |
| 94 | - assert !p.errors.invalid?(:owner) | |
| 94 | + assert !p.errors[:owner.to_s].present? | |
| 95 | 95 | end |
| 96 | 96 | |
| 97 | 97 | should 'create a production cost on an enterprise' do | ... | ... |
test/unit/profile_test.rb
| ... | ... | @@ -7,31 +7,31 @@ class ProfileTest < ActiveSupport::TestCase |
| 7 | 7 | def test_identifier_validation |
| 8 | 8 | p = Profile.new |
| 9 | 9 | p.valid? |
| 10 | - assert p.errors.invalid?(:identifier) | |
| 10 | + assert p.errors[:identifier.to_s].present? | |
| 11 | 11 | |
| 12 | 12 | p.identifier = 'with space' |
| 13 | 13 | p.valid? |
| 14 | - assert p.errors.invalid?(:identifier) | |
| 14 | + assert p.errors[:identifier.to_s].present? | |
| 15 | 15 | |
| 16 | 16 | p.identifier = 'áéíóú' |
| 17 | 17 | p.valid? |
| 18 | - assert p.errors.invalid?(:identifier) | |
| 18 | + assert p.errors[:identifier.to_s].present? | |
| 19 | 19 | |
| 20 | 20 | p.identifier = 'rightformat2007' |
| 21 | 21 | p.valid? |
| 22 | - assert ! p.errors.invalid?(:identifier) | |
| 22 | + assert ! p.errors[:identifier.to_s].present? | |
| 23 | 23 | |
| 24 | 24 | p.identifier = 'rightformat' |
| 25 | 25 | p.valid? |
| 26 | - assert ! p.errors.invalid?(:identifier) | |
| 26 | + assert ! p.errors[:identifier.to_s].present? | |
| 27 | 27 | |
| 28 | 28 | p.identifier = 'right_format' |
| 29 | 29 | p.valid? |
| 30 | - assert ! p.errors.invalid?(:identifier) | |
| 30 | + assert ! p.errors[:identifier.to_s].present? | |
| 31 | 31 | |
| 32 | 32 | p.identifier = 'identifier-with-dashes' |
| 33 | 33 | p.valid? |
| 34 | - assert ! p.errors.invalid?(:identifier), 'Profile should accept identifier with dashes' | |
| 34 | + assert ! p.errors[:identifier.to_s].present?, 'Profile should accept identifier with dashes' | |
| 35 | 35 | end |
| 36 | 36 | |
| 37 | 37 | def test_has_domains |
| ... | ... | @@ -81,10 +81,10 @@ class ProfileTest < ActiveSupport::TestCase |
| 81 | 81 | def test_name_should_be_mandatory |
| 82 | 82 | p = Profile.new |
| 83 | 83 | p.valid? |
| 84 | - assert p.errors.invalid?(:name) | |
| 84 | + assert p.errors[:name.to_s].present? | |
| 85 | 85 | p.name = 'a very unprobable name' |
| 86 | 86 | p.valid? |
| 87 | - assert !p.errors.invalid?(:name) | |
| 87 | + assert !p.errors[:name.to_s].present? | |
| 88 | 88 | end |
| 89 | 89 | |
| 90 | 90 | def test_can_have_affiliated_people |
| ... | ... | @@ -1348,12 +1348,12 @@ class ProfileTest < ActiveSupport::TestCase |
| 1348 | 1348 | template = fast_create(Profile) |
| 1349 | 1349 | profile = Profile.new(:template => template) |
| 1350 | 1350 | !profile.valid? |
| 1351 | - assert profile.errors.invalid?(:template) | |
| 1351 | + assert profile.errors[:template.to_s].present? | |
| 1352 | 1352 | |
| 1353 | 1353 | template.is_template = true |
| 1354 | 1354 | template.save! |
| 1355 | 1355 | profile.valid? |
| 1356 | - assert !profile.errors.invalid?(:template) | |
| 1356 | + assert !profile.errors[:template.to_s].present? | |
| 1357 | 1357 | end |
| 1358 | 1358 | |
| 1359 | 1359 | should 'be able to have a template' do |
| ... | ... | @@ -1491,7 +1491,7 @@ class ProfileTest < ActiveSupport::TestCase |
| 1491 | 1491 | profile = Profile.new |
| 1492 | 1492 | profile.description = long_description |
| 1493 | 1493 | profile.valid? |
| 1494 | - assert profile.errors.invalid?(:description) | |
| 1494 | + assert profile.errors[:description.to_s].present? | |
| 1495 | 1495 | end |
| 1496 | 1496 | |
| 1497 | 1497 | should 'sanitize name before validation' do |
| ... | ... | @@ -1499,7 +1499,7 @@ class ProfileTest < ActiveSupport::TestCase |
| 1499 | 1499 | profile.name = "<h1 Bla </h1>" |
| 1500 | 1500 | profile.valid? |
| 1501 | 1501 | |
| 1502 | - assert profile.errors.invalid?(:name) | |
| 1502 | + assert profile.errors[:name.to_s].present? | |
| 1503 | 1503 | end |
| 1504 | 1504 | |
| 1505 | 1505 | should 'filter fields with white_list filter' do |
| ... | ... | @@ -1778,7 +1778,7 @@ class ProfileTest < ActiveSupport::TestCase |
| 1778 | 1778 | def assert_invalid_identifier(id) |
| 1779 | 1779 | profile = Profile.new(:identifier => id) |
| 1780 | 1780 | assert !profile.valid? |
| 1781 | - assert profile.errors.invalid?(:identifier) | |
| 1781 | + assert profile.errors[:identifier.to_s].present? | |
| 1782 | 1782 | end |
| 1783 | 1783 | |
| 1784 | 1784 | should 'respond to redirection_after_login' do |
| ... | ... | @@ -1801,12 +1801,12 @@ class ProfileTest < ActiveSupport::TestCase |
| 1801 | 1801 | profile = fast_create(Profile) |
| 1802 | 1802 | profile.redirection_after_login = 'invalid_option' |
| 1803 | 1803 | profile.save |
| 1804 | - assert profile.errors.invalid?(:redirection_after_login) | |
| 1804 | + assert profile.errors[:redirection_after_login.to_s].present? | |
| 1805 | 1805 | |
| 1806 | 1806 | Environment.login_redirection_options.keys.each do |redirection| |
| 1807 | 1807 | profile.redirection_after_login = redirection |
| 1808 | 1808 | profile.save |
| 1809 | - assert !profile.errors.invalid?(:redirection_after_login) | |
| 1809 | + assert !profile.errors[:redirection_after_login.to_s].present? | |
| 1810 | 1810 | end |
| 1811 | 1811 | end |
| 1812 | 1812 | ... | ... |
test/unit/rss_feed_test.rb
| ... | ... | @@ -15,7 +15,7 @@ class RssFeedTest < ActiveSupport::TestCase |
| 15 | 15 | :search => 'parent_and_children', |
| 16 | 16 | } |
| 17 | 17 | feed.valid? |
| 18 | - assert !feed.errors.invalid?('body') | |
| 18 | + assert !feed.errors['body'.to_s].present? | |
| 19 | 19 | end |
| 20 | 20 | |
| 21 | 21 | should 'alias body as "settings"' do |
| ... | ... | @@ -160,25 +160,25 @@ class RssFeedTest < ActiveSupport::TestCase |
| 160 | 160 | feed = RssFeed.new |
| 161 | 161 | feed.limit = 'text' |
| 162 | 162 | feed.valid? |
| 163 | - assert feed.errors.invalid?(:limit) | |
| 163 | + assert feed.errors[:limit.to_s].present? | |
| 164 | 164 | feed.limit = 10 |
| 165 | 165 | feed.valid? |
| 166 | - assert !feed.errors.invalid?(:limit) | |
| 166 | + assert !feed.errors[:limit.to_s].present? | |
| 167 | 167 | end |
| 168 | 168 | |
| 169 | 169 | should 'allow only parent_and_children and all as include setting' do |
| 170 | 170 | feed = RssFeed.new |
| 171 | 171 | feed.include = :something_else |
| 172 | 172 | feed.valid? |
| 173 | - assert feed.errors.invalid?(:include) | |
| 173 | + assert feed.errors[:include.to_s].present? | |
| 174 | 174 | |
| 175 | 175 | feed.include = 'parent_and_children' |
| 176 | 176 | feed.valid? |
| 177 | - assert !feed.errors.invalid?(:include) | |
| 177 | + assert !feed.errors[:include.to_s].present? | |
| 178 | 178 | |
| 179 | 179 | feed.include = 'all' |
| 180 | 180 | feed.valid? |
| 181 | - assert !feed.errors.invalid?(:include) | |
| 181 | + assert !feed.errors[:include.to_s].present? | |
| 182 | 182 | end |
| 183 | 183 | |
| 184 | 184 | should 'provide proper short description' do | ... | ... |
test/unit/scrap_test.rb
| ... | ... | @@ -4,35 +4,35 @@ class ScrapTest < ActiveSupport::TestCase |
| 4 | 4 | should "have the content" do |
| 5 | 5 | s = Scrap.new |
| 6 | 6 | s.valid? |
| 7 | - assert s.errors.invalid?(:content) | |
| 7 | + assert s.errors[:content.to_s].present? | |
| 8 | 8 | |
| 9 | 9 | s.content = '' |
| 10 | 10 | s.valid? |
| 11 | - assert s.errors.invalid?(:content) | |
| 11 | + assert s.errors[:content.to_s].present? | |
| 12 | 12 | |
| 13 | 13 | s.content = 'some content' |
| 14 | 14 | s.valid? |
| 15 | - assert !s.errors.invalid?(:content) | |
| 15 | + assert !s.errors[:content.to_s].present? | |
| 16 | 16 | end |
| 17 | 17 | |
| 18 | 18 | should "have the sender" do |
| 19 | 19 | s = Scrap.new |
| 20 | 20 | s.valid? |
| 21 | - assert s.errors.invalid?(:sender_id) | |
| 21 | + assert s.errors[:sender_id.to_s].present? | |
| 22 | 22 | |
| 23 | 23 | s.sender_id = 1 |
| 24 | 24 | s.valid? |
| 25 | - assert !s.errors.invalid?(:sender_id) | |
| 25 | + assert !s.errors[:sender_id.to_s].present? | |
| 26 | 26 | end |
| 27 | 27 | |
| 28 | 28 | should "have the receiver" do |
| 29 | 29 | s = Scrap.new |
| 30 | 30 | s.valid? |
| 31 | - assert s.errors.invalid?(:receiver_id) | |
| 31 | + assert s.errors[:receiver_id.to_s].present? | |
| 32 | 32 | |
| 33 | 33 | s.receiver_id = 1 |
| 34 | 34 | s.valid? |
| 35 | - assert !s.errors.invalid?(:receiver_id) | |
| 35 | + assert !s.errors[:receiver_id.to_s].present? | |
| 36 | 36 | end |
| 37 | 37 | |
| 38 | 38 | should "be associated to Person as sender" do | ... | ... |
test/unit/suggest_article_test.rb
| ... | ... | @@ -12,37 +12,37 @@ class SuggestArticleTest < ActiveSupport::TestCase |
| 12 | 12 | |
| 13 | 13 | should 'have the article_name' do |
| 14 | 14 | t = SuggestArticle.new |
| 15 | - assert !t.errors.invalid?(:article_name) | |
| 15 | + assert !t.errors[:article_name.to_s].present? | |
| 16 | 16 | t.valid? |
| 17 | - assert t.errors.invalid?(:article_name) | |
| 17 | + assert t.errors[:article_name.to_s].present? | |
| 18 | 18 | end |
| 19 | 19 | |
| 20 | 20 | should 'have the article_body' do |
| 21 | 21 | t = SuggestArticle.new |
| 22 | - assert !t.errors.invalid?(:article_body) | |
| 22 | + assert !t.errors[:article_body.to_s].present? | |
| 23 | 23 | t.valid? |
| 24 | - assert t.errors.invalid?(:article_body) | |
| 24 | + assert t.errors[:article_body.to_s].present? | |
| 25 | 25 | end |
| 26 | 26 | |
| 27 | 27 | should 'have the email' do |
| 28 | 28 | t = SuggestArticle.new |
| 29 | - assert !t.errors.invalid?(:email) | |
| 29 | + assert !t.errors[:email.to_s].present? | |
| 30 | 30 | t.valid? |
| 31 | - assert t.errors.invalid?(:email) | |
| 31 | + assert t.errors[:email.to_s].present? | |
| 32 | 32 | end |
| 33 | 33 | |
| 34 | 34 | should 'have the name' do |
| 35 | 35 | t = SuggestArticle.new |
| 36 | - assert !t.errors.invalid?(:name) | |
| 36 | + assert !t.errors[:name.to_s].present? | |
| 37 | 37 | t.valid? |
| 38 | - assert t.errors.invalid?(:name) | |
| 38 | + assert t.errors[:name.to_s].present? | |
| 39 | 39 | end |
| 40 | 40 | |
| 41 | 41 | should 'have the target_id' do |
| 42 | 42 | t = SuggestArticle.new |
| 43 | - assert !t.errors.invalid?(:target_id) | |
| 43 | + assert !t.errors[:target_id.to_s].present? | |
| 44 | 44 | t.valid? |
| 45 | - assert t.errors.invalid?(:target_id) | |
| 45 | + assert t.errors[:target_id.to_s].present? | |
| 46 | 46 | end |
| 47 | 47 | |
| 48 | 48 | should 'have the article_abstract' do | ... | ... |
test/unit/task_test.rb
| ... | ... | @@ -115,7 +115,7 @@ class TaskTest < ActiveSupport::TestCase |
| 115 | 115 | task2 = Task.new(:code => task1.code) |
| 116 | 116 | |
| 117 | 117 | assert !task2.valid? |
| 118 | - assert task2.errors.invalid?(:code) | |
| 118 | + assert task2.errors[:code.to_s].present? | |
| 119 | 119 | end |
| 120 | 120 | |
| 121 | 121 | should 'generate a code with chars from a-z and 0-9' do | ... | ... |
test/unit/user_test.rb
| ... | ... | @@ -90,27 +90,27 @@ class UserTest < ActiveSupport::TestCase |
| 90 | 90 | def test_login_validation |
| 91 | 91 | u = User.new |
| 92 | 92 | u.valid? |
| 93 | - assert u.errors.invalid?(:login) | |
| 93 | + assert u.errors[:login.to_s].present? | |
| 94 | 94 | |
| 95 | 95 | u.login = 'with space' |
| 96 | 96 | u.valid? |
| 97 | - assert u.errors.invalid?(:login) | |
| 97 | + assert u.errors[:login.to_s].present? | |
| 98 | 98 | |
| 99 | 99 | u.login = 'áéíóú' |
| 100 | 100 | u.valid? |
| 101 | - assert u.errors.invalid?(:login) | |
| 101 | + assert u.errors[:login.to_s].present? | |
| 102 | 102 | |
| 103 | 103 | u.login = 'rightformat2007' |
| 104 | 104 | u.valid? |
| 105 | - assert ! u.errors.invalid?(:login) | |
| 105 | + assert ! u.errors[:login.to_s].present? | |
| 106 | 106 | |
| 107 | 107 | u.login = 'rightformat' |
| 108 | 108 | u.valid? |
| 109 | - assert ! u.errors.invalid?(:login) | |
| 109 | + assert ! u.errors[:login.to_s].present? | |
| 110 | 110 | |
| 111 | 111 | u.login = 'right_format' |
| 112 | 112 | u.valid? |
| 113 | - assert ! u.errors.invalid?(:login) | |
| 113 | + assert ! u.errors[:login.to_s].present? | |
| 114 | 114 | end |
| 115 | 115 | |
| 116 | 116 | def test_should_change_password | ... | ... |