Commit 6d2a0edf0ec3ab1d1f07cac36cc5b29d5d48c3ba

Authored by Rodrigo Souto
1 parent 4001b435

rails3: refactor deprecated invalid? of ActiveRecord::Errors from all tests

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