diff --git a/app/models/add_member.rb b/app/models/add_member.rb index 3731c15..50512ab 100644 --- a/app/models/add_member.rb +++ b/app/models/add_member.rb @@ -22,7 +22,7 @@ class AddMember < Task self.roles = [Profile::Roles.member(organization.environment.id).id] end target.affiliate(requestor, self.roles.select{|r| !r.to_i.zero? }.map{|i| Role.find(i)}) - person.follow(organization, Circle.find_or_create_by(:person => person, :name =>_('memberships'), :profile_type => 'Community')) + person.follow(organization, Circle.find_or_create_by(:owner => person, :name =>_('memberships'), :profile_type => 'Community')) end def title diff --git a/app/models/circle.rb b/app/models/circle.rb index 4a7372f..423b444 100644 --- a/app/models/circle.rb +++ b/app/models/circle.rb @@ -25,7 +25,8 @@ class Circle < ApplicationRecord { _("Person") => Person.name, _("Community") => Community.name, - _("Enterprise") => Enterprise.name + _("Enterprise") => Enterprise.name, + _("Organization") => Organization.name } end diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index 82a4fdf..0a93fcb 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -1101,7 +1101,7 @@ class ArticleTest < ActiveSupport::TestCase should 'create notifications to followers when creating an article' do friend = fast_create(Person) - circle = Circle.create!(:person=> friend, :name => "Zombies", :profile_type => 'Person') + circle = Circle.create!(:owner=> friend, :name => "Zombies", :profile_type => 'Person') friend.follow(profile, circle) Article.destroy_all ActionTracker::Record.destroy_all @@ -1115,7 +1115,7 @@ class ArticleTest < ActiveSupport::TestCase should 'create the notification to the follower when one follower has the notification and the other no' do f1 = fast_create(Person) - circle = Circle.create!(:person=> f1, :name => "Zombies", :profile_type => 'Person') + circle = Circle.create!(:owner=> f1, :name => "Zombies", :profile_type => 'Person') f1.follow(profile, circle) User.current = profile.user @@ -1125,7 +1125,7 @@ class ArticleTest < ActiveSupport::TestCase assert_equal 2, ActionTrackerNotification.where(action_tracker_id: article.activity.id).count f2 = fast_create(Person) - circle2 = Circle.create!(:person=> f2, :name => "Zombies", :profile_type => 'Person') + circle2 = Circle.create!(:owner=> f2, :name => "Zombies", :profile_type => 'Person') f2.follow(profile, circle2) article2 = create TinyMceArticle, :name => 'Tracked Article 2', :profile_id => profile.id @@ -1137,7 +1137,7 @@ class ArticleTest < ActiveSupport::TestCase should 'destroy activity and notifications of followers when destroying an article' do friend = fast_create(Person) - circle = Circle.create!(:person=> friend, :name => "Zombies", :profile_type => 'Person') + circle = Circle.create!(:owner=> friend, :name => "Zombies", :profile_type => 'Person') friend.follow(profile, circle) diff --git a/test/unit/follower_test.rb b/test/unit/follower_test.rb index c0ae8ec..590fb49 100644 --- a/test/unit/follower_test.rb +++ b/test/unit/follower_test.rb @@ -8,6 +8,7 @@ class FollowerTest < ActiveSupport::TestCase @circle1 = Circle.create!(owner: @person1, name: "Zombies", profile_type: 'Person') @circle2 = Circle.create!(owner: @person1, name: "Humans", profile_type: 'Person') + @circle3 = Circle.create!(owner: @person1, name: "Crypt", profile_type: 'Community') @external_person = ExternalPerson.create!(identifier: 'johnlocke', name: 'John Locke', @@ -85,27 +86,32 @@ class FollowerTest < ActiveSupport::TestCase should 'get the followed profiles for a regular user' do person3 = create_user('person-test-3').person + community = fast_create(Community) @person1.follow(@person2, @circle1) @person1.follow(person3, @circle1) - assert_equivalent [@person2, person3], @person1.followed_profiles + @person1.follow(community, @circle3) + assert_equivalent [@person2, person3, community], @person1.followed_profiles end should 'get the followed profiles for an external user' do person3 = create_user('person-test-3').person + community = fast_create(Community) @circle1.update_attributes(owner: @external_person) + @circle3.update_attributes(owner: @external_person) @external_person.follow(@person2, @circle1) @external_person.follow(person3, @circle1) - assert_equivalent [@person2, person3], @external_person.followed_profiles + @external_person.follow(community, @circle3) + assert_equivalent [@person2, person3, community], @external_person.followed_profiles end should 'not follow same person twice even with different circles' do - circle3 = Circle.create!(owner: @person1, name: "Free Folk", profile_type: 'Person') + circle4 = Circle.create!(owner: @person1, name: "Free Folk", profile_type: 'Person') @person1.follow(@person2, @circle1) @person1.follow(@person2, @circle2) - @person1.follow(@person2, circle3) + @person1.follow(@person2, circle4) assert_equivalent [@person2], @person1.followed_profiles end @@ -118,21 +124,21 @@ class FollowerTest < ActiveSupport::TestCase end should 'update profile circles for a person' do - circle3 = Circle.create!(owner: @person1, name: "Brains", profile_type: 'Person') + circle4 = Circle.create!(owner: @person1, name: "Brains", profile_type: 'Person') @person1.follow(@person2, [@circle1, @circle2]) - @person1.update_profile_circles(@person2, [@circle2, circle3]) - assert_equivalent [@circle2, circle3], @person2.circles + @person1.update_profile_circles(@person2, [@circle2, circle4]) + assert_equivalent [@circle2, circle4], @person2.circles end should 'keep other follower circles after update' do person3 = create_user('person-test-3').person - circle3 = Circle.create!(owner: person3, name: "Humans", profile_type: 'Person') + circle4 = Circle.create!(owner: person3, name: "Humans", profile_type: 'Person') @person1.follow(@person2, @circle1) - person3.follow(@person2, circle3) + person3.follow(@person2, circle4) @person1.update_profile_circles(@person2, [@circle1, @circle2]) - assert_equivalent [@circle1, @circle2, circle3], @person2.circles + assert_equivalent [@circle1, @circle2, circle4], @person2.circles end should 'remove a person from a circle' do diff --git a/test/unit/friendship_test.rb b/test/unit/friendship_test.rb index c5fd147..e1b2045 100644 --- a/test/unit/friendship_test.rb +++ b/test/unit/friendship_test.rb @@ -115,8 +115,8 @@ class FriendshipTest < ActiveSupport::TestCase p1 = create_user('testuser1').person p2 = create_user('testuser2').person - circle1 = Circle.create!(:person=> p1, :name => "Zombies", :profile_type => 'Person') - circle2 = Circle.create!(:person=> p2, :name => "Zombies", :profile_type => 'Person') + circle1 = Circle.create!(:owner=> p1, :name => "Zombies", :profile_type => 'Person') + circle2 = Circle.create!(:owner=> p2, :name => "Zombies", :profile_type => 'Person') p1.follow(p2, circle1) p2.follow(p1, circle2) diff --git a/test/unit/notify_activity_to_profiles_job_test.rb b/test/unit/notify_activity_to_profiles_job_test.rb index c0e6ed5..b12fa43 100644 --- a/test/unit/notify_activity_to_profiles_job_test.rb +++ b/test/unit/notify_activity_to_profiles_job_test.rb @@ -31,9 +31,9 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase 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) - circle1 = Circle.create!(:person=> p1, :name => "Zombies", :profile_type => 'Person') - circle2 = Circle.create!(:person=> p2, :name => "Zombies", :profile_type => 'Person') - circle = Circle.create!(:person=> person, :name => "Zombies", :profile_type => 'Person') + circle1 = Circle.create!(:owner=> p1, :name => "Zombies", :profile_type => 'Person') + circle2 = Circle.create!(:owner=> p2, :name => "Zombies", :profile_type => 'Person') + circle = Circle.create!(:owner=> person, :name => "Zombies", :profile_type => 'Person') fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle1.id) fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle2.id) @@ -79,7 +79,7 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase 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) - circle1 = Circle.create!(:person=> p1, :name => "Zombies", :profile_type => 'Person') + circle1 = Circle.create!(:owner=> p1, :name => "Zombies", :profile_type => 'Person') fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle1.id) fast_create(RoleAssignment, :accessor_id => m1.id, :role_id => 3, :resource_id => community.id) @@ -127,8 +127,8 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase 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) - circle1 = Circle.create!(:person=> p1, :name => "Zombies", :profile_type => 'Person') - circle2 = Circle.create!(:person=> p2, :name => "Zombies", :profile_type => 'Person') + circle1 = Circle.create!(:owner=> p1, :name => "Zombies", :profile_type => 'Person') + circle2 = Circle.create!(:owner=> p2, :name => "Zombies", :profile_type => 'Person') fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle1.id) fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle2.id) diff --git a/test/unit/organization_test.rb b/test/unit/organization_test.rb index 8ad3e99..cbb6466 100644 --- a/test/unit/organization_test.rb +++ b/test/unit/organization_test.rb @@ -267,9 +267,9 @@ class OrganizationTest < ActiveSupport::TestCase o.add_member(p3) assert p3.is_member_of?(o) - assert_equal true, o.send(:followed_by?,p1) - assert_equal true, o.send(:followed_by?,p3) - assert_equal false, o.send(:followed_by?,p2) + assert o.followed_by? p1 + assert o.followed_by? p3 + refute o.followed_by? p2 end should "compose bare jabber id by identifier plus 'conference' and default hostname" do diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index ff48e6f..4938789 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -2249,30 +2249,4 @@ class ProfileTest < ActiveSupport::TestCase assert_equivalent person3.followers, [person1, person2] end - should 'return all profiles followed by a regular person' do - person1 = create_user('testperson-1').person - person2 = create_user('testperson-2').person - community = fast_create(Community) - circle1 = Circle.create!(:owner => person1, :name => "Night's Watch", :profile_type => 'Person') - circle2 = Circle.create!(:owner => person1, :name => "Free Folk", :profile_type => 'Community') - - person1.follow(person2, circle1) - person1.follow(community, circle2) - assert_equivalent [person2, community], Profile.followed_by(person1) - end - - should 'return all profiles followed by an external person' do - external_person = ExternalPerson.create!(identifier: 'johnlocke', name: 'John Locke', - source: 'anerenvironment.org', email: 'locke@island.org', - created_at: Date.yesterday) - person = create_user('testperson-2').person - community = fast_create(Community) - circle1 = Circle.create!(:owner => external_person, :name => "Night's Watch", :profile_type => 'Person') - circle2 = Circle.create!(:owner => external_person, :name => "Free Folk", :profile_type => 'Community') - - external_person.follow(person, circle1) - external_person.follow(community, circle2) - assert_equivalent [person, community], Profile.followed_by(external_person) - end - end -- libgit2 0.21.2