Commit 514174be70ab846259d0999114eafe2f502089a6

Authored by Daniela Feitosa
1 parent 445e5140

ActionItem1067: fixing tests

test/functional/profile_controller_test.rb
@@ -258,6 +258,7 @@ class ProfileControllerTest < Test::Unit::TestCase @@ -258,6 +258,7 @@ class ProfileControllerTest < Test::Unit::TestCase
258 login_as(@profile.identifier) 258 login_as(@profile.identifier)
259 friend = create_user('friendtestuser').person 259 friend = create_user('friendtestuser').person
260 @profile.add_friend(friend) 260 @profile.add_friend(friend)
  261 + @profile.friends.reload
261 assert @profile.is_a_friend?(friend) 262 assert @profile.is_a_friend?(friend)
262 get :index, :profile => friend.identifier 263 get :index, :profile => friend.identifier
263 assert_no_tag :tag => 'a', :content => 'Add friend' 264 assert_no_tag :tag => 'a', :content => 'Add friend'
test/unit/add_friend_test.rb
@@ -15,6 +15,8 @@ class AddFriendTest < ActiveSupport::TestCase @@ -15,6 +15,8 @@ class AddFriendTest < ActiveSupport::TestCase
15 assert_difference Friendship, :count, 2 do 15 assert_difference Friendship, :count, 2 do
16 task.finish 16 task.finish
17 end 17 end
  18 + p1.friends.reload
  19 + p2.friends.reload
18 20
19 ok('p1 should have p2 as friend') { p1.friends.include?(p2) } 21 ok('p1 should have p2 as friend') { p1.friends.include?(p2) }
20 ok('p2 should have p1 as friend') { p2.friends.include?(p1) } 22 ok('p2 should have p1 as friend') { p2.friends.include?(p1) }
test/unit/blog_helper_test.rb
@@ -20,7 +20,7 @@ class BlogHelperTest < Test::Unit::TestCase @@ -20,7 +20,7 @@ class BlogHelperTest < Test::Unit::TestCase
20 blog.children << published_post = TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => true) 20 blog.children << published_post = TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => true)
21 21
22 expects(:display_post).with(anything).returns('POST') 22 expects(:display_post).with(anything).returns('POST')
23 - expects(:content_tag).with('div', 'POST', :class => 'blog-post position-1 first last', :id => "post-#{published_post.id}").returns('RESULT') 23 + expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", :class => 'blog-post position-1 first last', :id => "post-#{published_post.id}").returns('RESULT')
24 24
25 assert_equal 'RESULT', list_posts(profile, blog.posts) 25 assert_equal 'RESULT', list_posts(profile, blog.posts)
26 end 26 end
@@ -29,7 +29,7 @@ class BlogHelperTest &lt; Test::Unit::TestCase @@ -29,7 +29,7 @@ class BlogHelperTest &lt; Test::Unit::TestCase
29 blog.children << unpublished_post = TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => false) 29 blog.children << unpublished_post = TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => false)
30 30
31 expects(:display_post).with(anything).returns('POST') 31 expects(:display_post).with(anything).returns('POST')
32 - expects(:content_tag).with('div', 'POST', :class => 'blog-post position-1 first last not-published', :id => "post-#{unpublished_post.id}").returns('RESULT') 32 + expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", :class => 'blog-post position-1 first last not-published', :id => "post-#{unpublished_post.id}").returns('RESULT')
33 33
34 assert_equal 'RESULT', list_posts(profile, blog.posts) 34 assert_equal 'RESULT', list_posts(profile, blog.posts)
35 end 35 end
@@ -40,8 +40,8 @@ class BlogHelperTest &lt; Test::Unit::TestCase @@ -40,8 +40,8 @@ class BlogHelperTest &lt; Test::Unit::TestCase
40 blog.children << published_post = TextileArticle.create!(:name => 'Second post', :profile => profile, :parent => blog, :published => true) 40 blog.children << published_post = TextileArticle.create!(:name => 'Second post', :profile => profile, :parent => blog, :published => true)
41 41
42 expects(:display_post).with(anything).returns('POST') 42 expects(:display_post).with(anything).returns('POST')
43 - expects(:content_tag).with('div', 'POST', has_entries(:id => "post-#{published_post.id}")).returns('RESULT')  
44 - expects(:content_tag).with('div', 'POST', has_entries(:id => "post-#{unpublished_post.id}")).never 43 + expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", has_entries(:id => "post-#{published_post.id}")).returns('RESULT')
  44 + expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", has_entries(:id => "post-#{unpublished_post.id}")).never
45 45
46 assert_equal 'RESULT', list_posts(nil, blog.posts) 46 assert_equal 'RESULT', list_posts(nil, blog.posts)
47 end 47 end
test/unit/friends_block_test.rb
@@ -25,6 +25,7 @@ class FriendsBlockTest &lt; ActiveSupport::TestCase @@ -25,6 +25,7 @@ class FriendsBlockTest &lt; ActiveSupport::TestCase
25 p1.add_friend(p2) 25 p1.add_friend(p2)
26 p1.add_friend(p3) 26 p1.add_friend(p3)
27 p1.add_friend(p4) 27 p1.add_friend(p4)
  28 + p1.friends.reload
28 29
29 block = FriendsBlock.new 30 block = FriendsBlock.new
30 block.expects(:owner).returns(p1) 31 block.expects(:owner).returns(p1)
test/unit/invite_friend_test.rb
@@ -16,6 +16,9 @@ class InviteFriendTest &lt; ActiveSupport::TestCase @@ -16,6 +16,9 @@ class InviteFriendTest &lt; ActiveSupport::TestCase
16 task.finish 16 task.finish
17 end 17 end
18 18
  19 + p1.friends.reload
  20 + p2.friends.reload
  21 +
19 ok('p1 should have p2 as friend') { p1.friends.include?(p2) } 22 ok('p1 should have p2 as friend') { p1.friends.include?(p2) }
20 ok('p2 should have p1 as friend') { p2.friends.include?(p1) } 23 ok('p2 should have p1 as friend') { p2.friends.include?(p1) }
21 end 24 end
test/unit/person_test.rb
@@ -194,6 +194,7 @@ class PersonTest &lt; Test::Unit::TestCase @@ -194,6 +194,7 @@ class PersonTest &lt; Test::Unit::TestCase
194 194
195 p1.add_friend(p2) 195 p1.add_friend(p2)
196 196
  197 + p1.friends.reload
197 assert_equal [p2], p1.friends 198 assert_equal [p2], p1.friends
198 199
199 p3 = create_user('testuser3').person 200 p3 = create_user('testuser3').person
@@ -344,7 +345,7 @@ class PersonTest &lt; Test::Unit::TestCase @@ -344,7 +345,7 @@ class PersonTest &lt; Test::Unit::TestCase
344 person.save! 345 person.save!
345 friend = create_user('test_friend').person 346 friend = create_user('test_friend').person
346 person.add_friend(friend) 347 person.add_friend(friend)
347 - 348 + person.friends.reload
348 assert person.display_info_to?(friend) 349 assert person.display_info_to?(friend)
349 end 350 end
350 351
@@ -500,6 +501,7 @@ class PersonTest &lt; Test::Unit::TestCase @@ -500,6 +501,7 @@ class PersonTest &lt; Test::Unit::TestCase
500 p1 = create_user('testuser1').person 501 p1 = create_user('testuser1').person
501 p2 = create_user('testuser2').person 502 p2 = create_user('testuser2').person
502 p1.add_friend(p2) 503 p1.add_friend(p2)
  504 + p1.friends.reload
503 assert p1.is_a_friend?(p2) 505 assert p1.is_a_friend?(p2)
504 end 506 end
505 507