diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index 68cb57f..6226eaa 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -1099,9 +1099,9 @@ class ArticleTest < ActiveSupport::TestCase assert_equal 3, ActionTrackerNotification.where(action_tracker_id: second_activity.id).count end - should 'create notifications to friends when creating an article' do + should 'create notifications to followers when creating an article' do friend = fast_create(Person) - profile.add_friend(friend) + friend.follow(profile) Article.destroy_all ActionTracker::Record.destroy_all ActionTrackerNotification.destroy_all @@ -1112,9 +1112,9 @@ class ArticleTest < ActiveSupport::TestCase assert_equal friend, ActionTrackerNotification.last.profile end - should 'create the notification to the friend when one friend has the notification and the other no' do + should 'create the notification to the follower when one follower has the notification and the other no' do f1 = fast_create(Person) - profile.add_friend(f1) + f1.follow(profile) User.current = profile.user article = create TinyMceArticle, :name => 'Tracked Article 1', :profile_id => profile.id @@ -1123,16 +1123,17 @@ class ArticleTest < ActiveSupport::TestCase assert_equal 2, ActionTrackerNotification.where(action_tracker_id: article.activity.id).count f2 = fast_create(Person) - profile.add_friend(f2) + f2.follow(profile) + article2 = create TinyMceArticle, :name => 'Tracked Article 2', :profile_id => profile.id assert_equal 2, ActionTracker::Record.where(verb: 'create_article').count process_delayed_job_queue assert_equal 3, ActionTrackerNotification.where(action_tracker_id: article2.activity.id).count end - should 'destroy activity and notifications of friends when destroying an article' do + should 'destroy activity and notifications of followers when destroying an article' do friend = fast_create(Person) - profile.add_friend(friend) + friend.follow(profile) Article.destroy_all ActionTracker::Record.destroy_all ActionTrackerNotification.destroy_all diff --git a/test/unit/notify_activity_to_profiles_job_test.rb b/test/unit/notify_activity_to_profiles_job_test.rb index 311113d..afa5972 100644 --- a/test/unit/notify_activity_to_profiles_job_test.rb +++ b/test/unit/notify_activity_to_profiles_job_test.rb @@ -24,15 +24,15 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase end end - should 'notify just the users and his friends tracking user actions' do + should 'notify just the users and his followers tracking user actions' do person = fast_create(Person) community = fast_create(Community) action_tracker = fast_create(ActionTracker::Record, :user_type => 'Profile', :user_id => person.id, :target_type => 'Profile', :verb => 'create_article') refute NotifyActivityToProfilesJob::NOTIFY_ONLY_COMMUNITY.include?(action_tracker.verb) p1, p2, m1, m2 = fast_create(Person), fast_create(Person), fast_create(Person), fast_create(Person) - fast_create(Friendship, :person_id => person.id, :friend_id => p1.id) - fast_create(Friendship, :person_id => person.id, :friend_id => p2.id) - fast_create(Friendship, :person_id => p1.id, :friend_id => m1.id) + fast_create(ProfileFollower, :profile_id => person.id, :follower_id => p1.id) + fast_create(ProfileFollower, :profile_id => person.id, :follower_id => p2.id) + fast_create(ProfileFollower, :profile_id => m1.id, :follower_id => person.id) fast_create(RoleAssignment, :accessor_id => m2.id, :role_id => 3, :resource_id => community.id) ActionTrackerNotification.delete_all job = NotifyActivityToProfilesJob.new(action_tracker.id) @@ -66,23 +66,21 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase end end - should 'notify users its friends, the community and its members' do + should 'notify users its followers, the community and its members' do person = fast_create(Person) community = fast_create(Community) action_tracker = fast_create(ActionTracker::Record, :user_type => 'Profile', :user_id => person.id, :target_type => 'Profile', :target_id => community.id, :verb => 'create_article') refute NotifyActivityToProfilesJob::NOTIFY_ONLY_COMMUNITY.include?(action_tracker.verb) p1, p2, m1, m2 = fast_create(Person), fast_create(Person), fast_create(Person), fast_create(Person) - fast_create(Friendship, :person_id => person.id, :friend_id => p1.id) - fast_create(Friendship, :person_id => person.id, :friend_id => p2.id) + fast_create(ProfileFollower, :profile_id => person.id, :follower_id => p1.id) fast_create(RoleAssignment, :accessor_id => m1.id, :role_id => 3, :resource_id => community.id) fast_create(RoleAssignment, :accessor_id => m2.id, :role_id => 3, :resource_id => community.id) ActionTrackerNotification.delete_all job = NotifyActivityToProfilesJob.new(action_tracker.id) job.perform process_delayed_job_queue - - assert_equal 6, ActionTrackerNotification.count - [person, community, p1, p2, m1, m2].each do |profile| + assert_equal 5, ActionTrackerNotification.count + [person, community, p1, m1, m2].each do |profile| notification = ActionTrackerNotification.find_by profile_id: profile.id assert_equal action_tracker, notification.action_tracker end @@ -119,8 +117,8 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase action_tracker = fast_create(ActionTracker::Record, :user_type => 'Profile', :user_id => person.id, :target_type => 'Profile', :target_id => community.id, :verb => 'join_community') refute NotifyActivityToProfilesJob::NOTIFY_ONLY_COMMUNITY.include?(action_tracker.verb) p1, p2, m1, m2 = fast_create(Person), fast_create(Person), fast_create(Person), fast_create(Person) - fast_create(Friendship, :person_id => person.id, :friend_id => p1.id) - fast_create(Friendship, :person_id => person.id, :friend_id => p2.id) + fast_create(ProfileFollower, :profile_id => person.id, :follower_id => p1.id) + fast_create(ProfileFollower, :profile_id => person.id, :follower_id => p2.id) fast_create(RoleAssignment, :accessor_id => m1.id, :role_id => 3, :resource_id => community.id) fast_create(RoleAssignment, :accessor_id => m2.id, :role_id => 3, :resource_id => community.id) ActionTrackerNotification.delete_all diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb index 440a8f6..f4ee39c 100644 --- a/test/unit/person_test.rb +++ b/test/unit/person_test.rb @@ -728,7 +728,7 @@ class PersonTest < ActiveSupport::TestCase assert_equal [s4], p2.scraps_received.not_replies end - should "the followed_by method be protected and true to the person friends and herself by default" do + should "the followed_by method return true to the person friends and herself by default" do p1 = fast_create(Person) p2 = fast_create(Person) p3 = fast_create(Person) @@ -740,9 +740,9 @@ class PersonTest < ActiveSupport::TestCase assert p1.is_a_friend?(p4) assert_equal true, p1.send(:followed_by?,p1) - assert_equal true, p1.send(:followed_by?,p2) - assert_equal true, p1.send(:followed_by?,p4) - assert_equal false, p1.send(:followed_by?,p3) + assert_equal true, p2.send(:followed_by?,p1) + assert_equal true, p4.send(:followed_by?,p1) + assert_equal false, p3.send(:followed_by?,p1) end should "the person follows her friends and herself by default" do @@ -757,9 +757,9 @@ class PersonTest < ActiveSupport::TestCase assert p4.is_a_friend?(p1) assert_equal true, p1.follows?(p1) - assert_equal true, p1.follows?(p2) - assert_equal true, p1.follows?(p4) - assert_equal false, p1.follows?(p3) + assert_equal true, p2.follows?(p1) + assert_equal true, p4.follows?(p1) + assert_equal false, p3.follows?(p1) end should "a person member of a community follows the community" do @@ -836,18 +836,18 @@ class PersonTest < ActiveSupport::TestCase assert_nil Scrap.find_by(id: scrap.id) end - should "the tracked action be notified to person friends and herself" do + should "the tracked action be notified to person followers and herself" do Person.destroy_all p1 = fast_create(Person) p2 = fast_create(Person) p3 = fast_create(Person) p4 = fast_create(Person) - p1.add_friend(p2) - assert p1.is_a_friend?(p2) - refute p1.is_a_friend?(p3) - p1.add_friend(p4) - assert p1.is_a_friend?(p4) + p2.follow(p1) + assert p2.follows?(p1) + refute p3.follows?(p1) + p4.follow(p1) + assert p4.follows?(p1) action_tracker = fast_create(ActionTracker::Record, :user_id => p1.id) ActionTrackerNotification.delete_all @@ -880,17 +880,17 @@ class PersonTest < ActiveSupport::TestCase end end - should "the tracked action notify friends with one delayed job process" do + should "the tracked action notify followers with one delayed job process" do p1 = fast_create(Person) p2 = fast_create(Person) p3 = fast_create(Person) p4 = fast_create(Person) - p1.add_friend(p2) - assert p1.is_a_friend?(p2) - refute p1.is_a_friend?(p3) - p1.add_friend(p4) - assert p1.is_a_friend?(p4) + p2.follow(p1) + assert p2.follows?(p1) + refute p3.follows?(p1) + p4.follow(p1) + assert p4.follows?(p1) action_tracker = fast_create(ActionTracker::Record, :user_id => p1.id) @@ -1039,6 +1039,7 @@ class PersonTest < ActiveSupport::TestCase process_delayed_job_queue c.add_member(p3) process_delayed_job_queue + assert_equal 4, ActionTracker::Record.count assert_equal 5, ActionTrackerNotification.count has_add_member_notification = false diff --git a/test/unit/scrap_test.rb b/test/unit/scrap_test.rb index fb68094..49e5c20 100644 --- a/test/unit/scrap_test.rb +++ b/test/unit/scrap_test.rb @@ -125,11 +125,11 @@ class ScrapTest < ActiveSupport::TestCase assert_equal c, ta.target end - should "notify leave_scrap action tracker verb to friends and itself" do + should "notify leave_scrap action tracker verb to followers and itself" do User.current = create_user p1 = User.current.person p2 = create_user.person - p1.add_friend(p2) + p2.add_friend(p1) process_delayed_job_queue s = Scrap.new s.sender= p1 @@ -180,11 +180,11 @@ class ScrapTest < ActiveSupport::TestCase assert_equal p, ta.user end - should "notify leave_scrap_to_self action tracker verb to friends and itself" do + should "notify leave_scrap_to_self action tracker verb to followers and itself" do User.current = create_user p1 = User.current.person p2 = create_user.person - p1.add_friend(p2) + p2.add_friend(p1) ActionTrackerNotification.delete_all Delayed::Job.delete_all s = Scrap.new -- libgit2 0.21.2