From 514174be70ab846259d0999114eafe2f502089a6 Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Sat, 6 Jun 2009 18:43:28 -0300 Subject: [PATCH] ActionItem1067: fixing tests --- test/functional/profile_controller_test.rb | 1 + test/unit/add_friend_test.rb | 2 ++ test/unit/blog_helper_test.rb | 8 ++++---- test/unit/friends_block_test.rb | 1 + test/unit/invite_friend_test.rb | 3 +++ test/unit/person_test.rb | 4 +++- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/test/functional/profile_controller_test.rb b/test/functional/profile_controller_test.rb index 49d34d1..a6aa7b2 100644 --- a/test/functional/profile_controller_test.rb +++ b/test/functional/profile_controller_test.rb @@ -258,6 +258,7 @@ class ProfileControllerTest < Test::Unit::TestCase login_as(@profile.identifier) friend = create_user('friendtestuser').person @profile.add_friend(friend) + @profile.friends.reload assert @profile.is_a_friend?(friend) get :index, :profile => friend.identifier assert_no_tag :tag => 'a', :content => 'Add friend' diff --git a/test/unit/add_friend_test.rb b/test/unit/add_friend_test.rb index 1e59029..023211f 100644 --- a/test/unit/add_friend_test.rb +++ b/test/unit/add_friend_test.rb @@ -15,6 +15,8 @@ class AddFriendTest < ActiveSupport::TestCase assert_difference Friendship, :count, 2 do task.finish end + p1.friends.reload + p2.friends.reload ok('p1 should have p2 as friend') { p1.friends.include?(p2) } ok('p2 should have p1 as friend') { p2.friends.include?(p1) } diff --git a/test/unit/blog_helper_test.rb b/test/unit/blog_helper_test.rb index 7c6e676..1d0e0ed 100644 --- a/test/unit/blog_helper_test.rb +++ b/test/unit/blog_helper_test.rb @@ -20,7 +20,7 @@ class BlogHelperTest < Test::Unit::TestCase blog.children << published_post = TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => true) expects(:display_post).with(anything).returns('POST') - expects(:content_tag).with('div', 'POST', :class => 'blog-post position-1 first last', :id => "post-#{published_post.id}").returns('RESULT') + expects(:content_tag).with('div', "POST
", :class => 'blog-post position-1 first last', :id => "post-#{published_post.id}").returns('RESULT') assert_equal 'RESULT', list_posts(profile, blog.posts) end @@ -29,7 +29,7 @@ class BlogHelperTest < Test::Unit::TestCase blog.children << unpublished_post = TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => false) expects(:display_post).with(anything).returns('POST') - expects(:content_tag).with('div', 'POST', :class => 'blog-post position-1 first last not-published', :id => "post-#{unpublished_post.id}").returns('RESULT') + expects(:content_tag).with('div', "POST
", :class => 'blog-post position-1 first last not-published', :id => "post-#{unpublished_post.id}").returns('RESULT') assert_equal 'RESULT', list_posts(profile, blog.posts) end @@ -40,8 +40,8 @@ class BlogHelperTest < Test::Unit::TestCase blog.children << published_post = TextileArticle.create!(:name => 'Second post', :profile => profile, :parent => blog, :published => true) expects(:display_post).with(anything).returns('POST') - expects(:content_tag).with('div', 'POST', has_entries(:id => "post-#{published_post.id}")).returns('RESULT') - expects(:content_tag).with('div', 'POST', has_entries(:id => "post-#{unpublished_post.id}")).never + expects(:content_tag).with('div', "POST
", has_entries(:id => "post-#{published_post.id}")).returns('RESULT') + expects(:content_tag).with('div', "POST
", has_entries(:id => "post-#{unpublished_post.id}")).never assert_equal 'RESULT', list_posts(nil, blog.posts) end diff --git a/test/unit/friends_block_test.rb b/test/unit/friends_block_test.rb index 50270ea..ad6778d 100644 --- a/test/unit/friends_block_test.rb +++ b/test/unit/friends_block_test.rb @@ -25,6 +25,7 @@ class FriendsBlockTest < ActiveSupport::TestCase p1.add_friend(p2) p1.add_friend(p3) p1.add_friend(p4) + p1.friends.reload block = FriendsBlock.new block.expects(:owner).returns(p1) diff --git a/test/unit/invite_friend_test.rb b/test/unit/invite_friend_test.rb index cf7b81d..76af476 100644 --- a/test/unit/invite_friend_test.rb +++ b/test/unit/invite_friend_test.rb @@ -16,6 +16,9 @@ class InviteFriendTest < ActiveSupport::TestCase task.finish end + p1.friends.reload + p2.friends.reload + ok('p1 should have p2 as friend') { p1.friends.include?(p2) } ok('p2 should have p1 as friend') { p2.friends.include?(p1) } end diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb index af58f8c..6904da3 100644 --- a/test/unit/person_test.rb +++ b/test/unit/person_test.rb @@ -194,6 +194,7 @@ class PersonTest < Test::Unit::TestCase p1.add_friend(p2) + p1.friends.reload assert_equal [p2], p1.friends p3 = create_user('testuser3').person @@ -344,7 +345,7 @@ class PersonTest < Test::Unit::TestCase person.save! friend = create_user('test_friend').person person.add_friend(friend) - + person.friends.reload assert person.display_info_to?(friend) end @@ -500,6 +501,7 @@ class PersonTest < Test::Unit::TestCase p1 = create_user('testuser1').person p2 = create_user('testuser2').person p1.add_friend(p2) + p1.friends.reload assert p1.is_a_friend?(p2) end -- libgit2 0.21.2