Commit 7e008527332c656705a5f295d3b1bafde368934d

Authored by Rodrigo Souto
1 parent fa8c4aac

[postgres-tests] Fixing person tests

Showing 1 changed file with 15 additions and 11 deletions   Show diff stats
test/unit/person_test.rb
@@ -819,7 +819,8 @@ class PersonTest < ActiveSupport::TestCase @@ -819,7 +819,8 @@ class PersonTest < ActiveSupport::TestCase
819 end 819 end
820 820
821 should "the tracked action be notified to person friends and herself" do 821 should "the tracked action be notified to person friends and herself" do
822 - p1 = Person.first 822 + Person.destroy_all
  823 + p1 = fast_create(Person)
823 p2 = fast_create(Person) 824 p2 = fast_create(Person)
824 p3 = fast_create(Person) 825 p3 = fast_create(Person)
825 p4 = fast_create(Person) 826 p4 = fast_create(Person)
@@ -829,14 +830,14 @@ class PersonTest < ActiveSupport::TestCase @@ -829,14 +830,14 @@ class PersonTest < ActiveSupport::TestCase
829 assert !p1.is_a_friend?(p3) 830 assert !p1.is_a_friend?(p3)
830 p1.add_friend(p4) 831 p1.add_friend(p4)
831 assert p1.is_a_friend?(p4) 832 assert p1.is_a_friend?(p4)
832 -  
833 - action_tracker = fast_create(ActionTracker::Record) 833 +
  834 + action_tracker = fast_create(ActionTracker::Record, :user_id => p1.id)
834 ActionTrackerNotification.delete_all 835 ActionTrackerNotification.delete_all
835 - count = ActionTrackerNotification.count  
836 Delayed::Job.destroy_all 836 Delayed::Job.destroy_all
837 - Person.notify_activity(action_tracker)  
838 - process_delayed_job_queue  
839 - assert_equal count + 3, ActionTrackerNotification.count 837 + assert_difference ActionTrackerNotification, :count, 3 do
  838 + Person.notify_activity(action_tracker)
  839 + process_delayed_job_queue
  840 + end
840 ActionTrackerNotification.all.map{|a|a.profile}.map do |profile| 841 ActionTrackerNotification.all.map{|a|a.profile}.map do |profile|
841 [p1,p2,p4].include?(profile) 842 [p1,p2,p4].include?(profile)
842 end 843 end
@@ -862,7 +863,7 @@ class PersonTest < ActiveSupport::TestCase @@ -862,7 +863,7 @@ class PersonTest < ActiveSupport::TestCase
862 end 863 end
863 864
864 should "the tracked action notify friends with one delayed job process" do 865 should "the tracked action notify friends with one delayed job process" do
865 - p1 = Person.first 866 + p1 = fast_create(Person)
866 p2 = fast_create(Person) 867 p2 = fast_create(Person)
867 p3 = fast_create(Person) 868 p3 = fast_create(Person)
868 p4 = fast_create(Person) 869 p4 = fast_create(Person)
@@ -873,7 +874,7 @@ class PersonTest < ActiveSupport::TestCase @@ -873,7 +874,7 @@ class PersonTest < ActiveSupport::TestCase
873 p1.add_friend(p4) 874 p1.add_friend(p4)
874 assert p1.is_a_friend?(p4) 875 assert p1.is_a_friend?(p4)
875 876
876 - action_tracker = fast_create(ActionTracker::Record) 877 + action_tracker = fast_create(ActionTracker::Record, :user_id => p1.id)
877 878
878 Delayed::Job.delete_all 879 Delayed::Job.delete_all
879 assert_difference(Delayed::Job, :count, 1) do 880 assert_difference(Delayed::Job, :count, 1) do
@@ -885,8 +886,9 @@ class PersonTest < ActiveSupport::TestCase @@ -885,8 +886,9 @@ class PersonTest < ActiveSupport::TestCase
885 end 886 end
886 887
887 should "the community tracked action be notified to the author and to community members" do 888 should "the community tracked action be notified to the author and to community members" do
888 - p1 = Person.first 889 + Person.destroy_all
889 community = fast_create(Community) 890 community = fast_create(Community)
  891 + p1 = fast_create(Person)
890 p2 = fast_create(Person) 892 p2 = fast_create(Person)
891 p3 = fast_create(Person) 893 p3 = fast_create(Person)
892 894
@@ -896,7 +898,7 @@ class PersonTest < ActiveSupport::TestCase @@ -896,7 +898,7 @@ class PersonTest < ActiveSupport::TestCase
896 assert p3.is_member_of?(community) 898 assert p3.is_member_of?(community)
897 assert !p2.is_member_of?(community) 899 assert !p2.is_member_of?(community)
898 process_delayed_job_queue 900 process_delayed_job_queue
899 - 901 +
900 action_tracker = fast_create(ActionTracker::Record, :verb => 'create_article') 902 action_tracker = fast_create(ActionTracker::Record, :verb => 'create_article')
901 action_tracker.target = community 903 action_tracker.target = community
902 action_tracker.save! 904 action_tracker.save!
@@ -1222,6 +1224,7 @@ class PersonTest < ActiveSupport::TestCase @@ -1222,6 +1224,7 @@ class PersonTest < ActiveSupport::TestCase
1222 end 1224 end
1223 1225
1224 should 'return tracked_actions and scraps as activities' do 1226 should 'return tracked_actions and scraps as activities' do
  1227 + ActionTracker::Record.destroy_all
1225 person = fast_create(Person) 1228 person = fast_create(Person)
1226 another_person = fast_create(Person) 1229 another_person = fast_create(Person)
1227 1230
@@ -1233,6 +1236,7 @@ class PersonTest < ActiveSupport::TestCase @@ -1233,6 +1236,7 @@ class PersonTest < ActiveSupport::TestCase
1233 end 1236 end
1234 1237
1235 should 'not return tracked_actions and scraps from others as activities' do 1238 should 'not return tracked_actions and scraps from others as activities' do
  1239 + ActionTracker::Record.destroy_all
1236 person = fast_create(Person) 1240 person = fast_create(Person)
1237 another_person = fast_create(Person) 1241 another_person = fast_create(Person)
1238 1242