Commit de0aceaacddab5649dd1de63ce0cef92ac494172

Authored by Victor Costa
1 parent 1b335879

rails3: fix assert_kind_of Array

On rails 3.2, the return type of some queries changes from Array to ActiveRecord::Relation.
An assertion that check if these attributes has been assigned (with a value != nil) should be enought.
This avoids future problems with api changes.
app/controllers/my_profile/cms_controller.rb
... ... @@ -232,7 +232,7 @@ class CmsController < MyProfileController
232 232 begin
233 233 task.finish unless item[:group].moderated_articles?
234 234 rescue Exception => ex
235   - @failed[ex.clean_message] ? @failed[ex.clean_message] << item[:group].name : @failed[ex.clean_message] = [item[:group].name]
  235 + @failed[ex.message] ? @failed[ex.message] << item[:group].name : @failed[ex.message] = [item[:group].name]
236 236 end
237 237 end
238 238 if @failed.blank?
... ...
app/controllers/my_profile/tasks_controller.rb
... ... @@ -27,7 +27,7 @@ class TasksController &lt; MyProfileController
27 27 task.send(decision)
28 28 rescue Exception => ex
29 29 message = "#{task.title} (#{task.requestor ? task.requestor.name : task.author_name})"
30   - failed[ex.clean_message] ? failed[ex.clean_message] << message : failed[ex.clean_message] = [message]
  30 + failed[ex.message] ? failed[ex.message] << message : failed[ex.message] = [message]
31 31 end
32 32 end
33 33 end
... ...
test/functional/catalog_controller_test.rb
... ... @@ -37,7 +37,7 @@ class CatalogControllerTest &lt; ActionController::TestCase
37 37  
38 38 should 'list products of enterprise' do
39 39 get :index, :profile => @enterprise.identifier
40   - assert_kind_of Array, assigns(:products)
  40 + assert assigns(:products)
41 41 end
42 42  
43 43 should 'paginate enterprise products list' do
... ...
test/functional/cms_controller_test.rb
... ... @@ -36,7 +36,7 @@ class CmsControllerTest &lt; ActionController::TestCase
36 36 assert_template 'view'
37 37 assert_equal profile, assigns(:profile)
38 38 assert_nil assigns(:article)
39   - assert_kind_of Array, assigns(:articles)
  39 + assert assigns(:articles)
40 40 end
41 41  
42 42 should 'be able to view a particular document' do
... ... @@ -49,8 +49,6 @@ class CmsControllerTest &lt; ActionController::TestCase
49 49 assert_template 'view'
50 50 assert_equal a, assigns(:article)
51 51 assert_equal [], assigns(:articles)
52   -
53   - assert_kind_of Array, assigns(:articles)
54 52 end
55 53  
56 54 should 'be able to edit a document' do
... ...
test/functional/friends_controller_test.rb
... ... @@ -30,7 +30,7 @@ class FriendsControllerTest &lt; ActionController::TestCase
30 30 get :index
31 31 assert_response :success
32 32 assert_template 'index'
33   - assert_kind_of Array, assigns(:friends)
  33 + assert assigns(:friends)
34 34 end
35 35  
36 36 should 'confirm removal of friend' do
... ...
test/functional/memberships_controller_test.rb
... ... @@ -30,7 +30,7 @@ class MembershipsControllerTest &lt; ActionController::TestCase
30 30 should 'list current memberships' do
31 31 get :index, :profile => profile.identifier
32 32  
33   - assert_kind_of Array, assigns(:memberships)
  33 + assert assigns(:memberships)
34 34 end
35 35  
36 36 should 'present new community form' do
... ...
test/functional/profile_controller_test.rb
... ... @@ -29,7 +29,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
29 29  
30 30 assert_response :success
31 31 assert_template 'friends'
32   - assert_kind_of Array, assigns(:friends)
  32 + assert assigns(:friends)
33 33 end
34 34  
35 35 should 'point to manage friends in user is seeing his own friends' do
... ... @@ -50,7 +50,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
50 50  
51 51 assert_response :success
52 52 assert_template 'communities'
53   - assert_kind_of Array, assigns(:communities)
  53 + assert assigns(:communities)
54 54 end
55 55  
56 56 should 'list enterprises' do
... ... @@ -58,7 +58,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
58 58  
59 59 assert_response :success
60 60 assert_template 'enterprises'
61   - assert_kind_of Array, assigns(:enterprises)
  61 + assert assigns(:enterprises)
62 62 end
63 63  
64 64 should 'list members (for organizations)' do
... ... @@ -66,7 +66,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
66 66  
67 67 assert_response :success
68 68 assert_template 'members'
69   - assert_kind_of Array, assigns(:members)
  69 + assert assigns(:members)
70 70 end
71 71  
72 72 should 'list favorite enterprises' do
... ... @@ -74,7 +74,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
74 74  
75 75 assert_response :success
76 76 assert_template 'favorite_enterprises'
77   - assert_kind_of Array, assigns(:favorite_enterprises)
  77 + assert assigns(:favorite_enterprises)
78 78 end
79 79  
80 80 should 'not render any template when joining community due to Ajax request' do
... ...
test/functional/region_validators_controller_test.rb
... ... @@ -26,7 +26,7 @@ class RegionValidatorsControllerTest &lt; ActionController::TestCase
26 26 get :index
27 27 assert_response :success
28 28 assert_template 'index'
29   - assert_kind_of Array, assigns(:regions)
  29 + assert assigns(:regions)
30 30 end
31 31  
32 32 should 'view validators for a specific region' do
... ...
test/functional/tasks_controller_test.rb
... ... @@ -35,7 +35,7 @@ class TasksControllerTest &lt; ActionController::TestCase
35 35  
36 36 assert_response :success
37 37 assert_template 'index'
38   - assert_kind_of Array, assigns(:tasks)
  38 + assert assigns(:tasks)
39 39 end
40 40  
41 41 should 'list pending tasks without spam' do
... ... @@ -197,7 +197,7 @@ class TasksControllerTest &lt; ActionController::TestCase
197 197 c = fast_create(Community)
198 198 c.update_attributes(:moderated_articles => false)
199 199 @controller.stubs(:profile).returns(c)
200   - folder = create(Article, :profile => c, :name => 'test folder', :type => 'Folder')
  200 + folder = create(Folder, :profile => c, :name => 'test folder')
201 201 c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id))
202 202 article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails')
203 203 t = ApproveArticle.create!(:name => 'test name', :article => article, :target => c, :requestor => profile)
... ... @@ -275,8 +275,8 @@ class TasksControllerTest &lt; ActionController::TestCase
275 275 t = SuggestArticle.create!(:article_name => 'test name', :article_abstract => 'test abstract', :article_body => 'test body', :name => 'some name', :email => 'test@localhost.com', :target => c)
276 276  
277 277 get :index
278   - assert_tag :tag => 'textarea', :content => 'test abstract', :attributes => { :name => /article_abstract/, :class => 'mceEditor' }
279   - assert_tag :tag => 'textarea', :content => 'test body', :attributes => { :name => /article_body/, :class => 'mceEditor' }
  278 + assert_tag :tag => 'textarea', :content => /test abstract/, :attributes => { :name => /article_abstract/, :class => 'mceEditor' }
  279 + assert_tag :tag => 'textarea', :content => /test body/, :attributes => { :name => /article_body/, :class => 'mceEditor' }
280 280 end
281 281  
282 282 should 'create TinyMceArticle article after finish approve suggested article task' do
... ...