Commit 8d2e48e91cbb60d5e1f6d6f413da4f9813c5b4f4
1 parent
bda87f25
Exists in
master
and in
29 other branches
ProfileController: fix fragile tests
Showing
1 changed file
with
12 additions
and
31 deletions
Show diff stats
test/functional/profile_controller_test.rb
@@ -737,13 +737,13 @@ class ProfileControllerTest < ActionController::TestCase | @@ -737,13 +737,13 @@ class ProfileControllerTest < ActionController::TestCase | ||
737 | end | 737 | end |
738 | 738 | ||
739 | should 'see all the activities in the current profile network' do | 739 | should 'see all the activities in the current profile network' do |
740 | - p1= fast_create(Person) | ||
741 | - p2= fast_create(Person) | 740 | + p1= create_user.person |
741 | + p2= create_user.person | ||
742 | assert !p1.is_a_friend?(p2) | 742 | assert !p1.is_a_friend?(p2) |
743 | 743 | ||
744 | - p3= fast_create(Person) | 744 | + p3= create_user.person |
745 | p3.add_friend(p1) | 745 | p3.add_friend(p1) |
746 | - assert p3.is_a_friend?(p1) | 746 | + p1.add_friend(p3) |
747 | 747 | ||
748 | ActionTracker::Record.delete_all | 748 | ActionTracker::Record.delete_all |
749 | 749 | ||
@@ -759,27 +759,21 @@ class ProfileControllerTest < ActionController::TestCase | @@ -759,27 +759,21 @@ class ProfileControllerTest < ActionController::TestCase | ||
759 | create(Scrap, defaults_for_scrap(:sender => p3, :receiver => p1)) | 759 | create(Scrap, defaults_for_scrap(:sender => p3, :receiver => p1)) |
760 | a3 = ActionTracker::Record.last | 760 | a3 = ActionTracker::Record.last |
761 | 761 | ||
762 | - @controller.stubs(:logged_in?).returns(true) | ||
763 | - user = mock() | ||
764 | - user.stubs(:person).returns(p3) | ||
765 | - user.stubs(:login).returns('some') | ||
766 | - @controller.stubs(:current_user).returns(user) | ||
767 | - Person.any_instance.stubs(:follows?).returns(true) | ||
768 | - | ||
769 | process_delayed_job_queue | 762 | process_delayed_job_queue |
770 | - get :index, :profile => p1.identifier | ||
771 | 763 | ||
764 | + login_as p3.user.login | ||
765 | + get :index, :profile => p1.identifier | ||
772 | assert_equivalent [a1,a3].map(&:id), assigns(:network_activities).map(&:id) | 766 | assert_equivalent [a1,a3].map(&:id), assigns(:network_activities).map(&:id) |
773 | end | 767 | end |
774 | 768 | ||
775 | should 'the network activity be visible only to profile followers' do | 769 | should 'the network activity be visible only to profile followers' do |
776 | - p1= fast_create(Person) | ||
777 | - p2= fast_create(Person) | 770 | + p1= create_user.person |
771 | + p2= create_user.person | ||
778 | assert !p1.is_a_friend?(p2) | 772 | assert !p1.is_a_friend?(p2) |
779 | 773 | ||
780 | - p3= fast_create(Person) | 774 | + p3= create_user.person |
781 | p3.add_friend(p1) | 775 | p3.add_friend(p1) |
782 | - assert p3.is_a_friend?(p1) | 776 | + p1.add_friend(p3) |
783 | 777 | ||
784 | ActionTracker::Record.delete_all | 778 | ActionTracker::Record.delete_all |
785 | 779 | ||
@@ -795,24 +789,11 @@ class ProfileControllerTest < ActionController::TestCase | @@ -795,24 +789,11 @@ class ProfileControllerTest < ActionController::TestCase | ||
795 | create(Scrap, defaults_for_scrap(:sender => p3, :receiver => p1)) | 789 | create(Scrap, defaults_for_scrap(:sender => p3, :receiver => p1)) |
796 | a3 = ActionTracker::Record.last | 790 | a3 = ActionTracker::Record.last |
797 | 791 | ||
798 | - @controller.stubs(:logged_in?).returns(true) | ||
799 | - user = mock() | ||
800 | - user.stubs(:person).returns(p2) | ||
801 | - user.stubs(:login).returns('some') | ||
802 | - @controller.stubs(:current_user).returns(user) | 792 | + process_delayed_job_queue |
803 | 793 | ||
794 | + login_as p2.user.login | ||
804 | get :index, :profile => p1.identifier | 795 | get :index, :profile => p1.identifier |
805 | assert assigns(:network_activities).blank? | 796 | assert assigns(:network_activities).blank? |
806 | - | ||
807 | - user = mock() | ||
808 | - user.stubs(:person).returns(p3) | ||
809 | - user.stubs(:login).returns('some') | ||
810 | - @controller.stubs(:current_user).returns(user) | ||
811 | - Person.any_instance.stubs(:follows?).returns(true) | ||
812 | - process_delayed_job_queue | ||
813 | - | ||
814 | - get :index, :profile => p3.identifier | ||
815 | - assert_equivalent [a1,a3], assigns(:network_activities) | ||
816 | end | 797 | end |
817 | 798 | ||
818 | should 'the network activity be paginated' do | 799 | should 'the network activity be paginated' do |