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 819 end
820 820  
821 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 824 p2 = fast_create(Person)
824 825 p3 = fast_create(Person)
825 826 p4 = fast_create(Person)
... ... @@ -829,14 +830,14 @@ class PersonTest < ActiveSupport::TestCase
829 830 assert !p1.is_a_friend?(p3)
830 831 p1.add_friend(p4)
831 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 835 ActionTrackerNotification.delete_all
835   - count = ActionTrackerNotification.count
836 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 841 ActionTrackerNotification.all.map{|a|a.profile}.map do |profile|
841 842 [p1,p2,p4].include?(profile)
842 843 end
... ... @@ -862,7 +863,7 @@ class PersonTest < ActiveSupport::TestCase
862 863 end
863 864  
864 865 should "the tracked action notify friends with one delayed job process" do
865   - p1 = Person.first
  866 + p1 = fast_create(Person)
866 867 p2 = fast_create(Person)
867 868 p3 = fast_create(Person)
868 869 p4 = fast_create(Person)
... ... @@ -873,7 +874,7 @@ class PersonTest < ActiveSupport::TestCase
873 874 p1.add_friend(p4)
874 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 879 Delayed::Job.delete_all
879 880 assert_difference(Delayed::Job, :count, 1) do
... ... @@ -885,8 +886,9 @@ class PersonTest < ActiveSupport::TestCase
885 886 end
886 887  
887 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 890 community = fast_create(Community)
  891 + p1 = fast_create(Person)
890 892 p2 = fast_create(Person)
891 893 p3 = fast_create(Person)
892 894  
... ... @@ -896,7 +898,7 @@ class PersonTest < ActiveSupport::TestCase
896 898 assert p3.is_member_of?(community)
897 899 assert !p2.is_member_of?(community)
898 900 process_delayed_job_queue
899   -
  901 +
900 902 action_tracker = fast_create(ActionTracker::Record, :verb => 'create_article')
901 903 action_tracker.target = community
902 904 action_tracker.save!
... ... @@ -1222,6 +1224,7 @@ class PersonTest < ActiveSupport::TestCase
1222 1224 end
1223 1225  
1224 1226 should 'return tracked_actions and scraps as activities' do
  1227 + ActionTracker::Record.destroy_all
1225 1228 person = fast_create(Person)
1226 1229 another_person = fast_create(Person)
1227 1230  
... ... @@ -1233,6 +1236,7 @@ class PersonTest < ActiveSupport::TestCase
1233 1236 end
1234 1237  
1235 1238 should 'not return tracked_actions and scraps from others as activities' do
  1239 + ActionTracker::Record.destroy_all
1236 1240 person = fast_create(Person)
1237 1241 another_person = fast_create(Person)
1238 1242  
... ...