Compare View
Commits (2)
-
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com> Signed-off-by: DylanGuedes <djmgguedes@gmail.com>
-
Signed-off-by: DylanGuedes <djmgguedes@gmail.com> Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
Showing
14 changed files
Show diff stats
app/models/add_member.rb
... | ... | @@ -22,7 +22,7 @@ class AddMember < Task |
22 | 22 | self.roles = [Profile::Roles.member(organization.environment.id).id] |
23 | 23 | end |
24 | 24 | target.affiliate(requestor, self.roles.select{|r| !r.to_i.zero? }.map{|i| Role.find(i)}) |
25 | - person.follow(organization, Circle.find_or_create_by(:person => person, :name =>_('memberships'), :profile_type => 'Community')) | |
25 | + person.follow(organization, Circle.find_or_create_by(:owner => person, :name =>_('memberships'), :profile_type => 'Community')) | |
26 | 26 | end |
27 | 27 | |
28 | 28 | def title | ... | ... |
app/models/circle.rb
... | ... | @@ -25,7 +25,8 @@ class Circle < ApplicationRecord |
25 | 25 | { |
26 | 26 | _("Person") => Person.name, |
27 | 27 | _("Community") => Community.name, |
28 | - _("Enterprise") => Enterprise.name | |
28 | + _("Enterprise") => Enterprise.name, | |
29 | + _("Organization") => Organization.name | |
29 | 30 | } |
30 | 31 | end |
31 | 32 | ... | ... |
... | ... | @@ -0,0 +1,18 @@ |
1 | +module Followable | |
2 | + extend ActiveSupport::Concern | |
3 | + | |
4 | + def followers | |
5 | + person_followers = Person.joins(:owned_circles).merge(circles).uniq | |
6 | + external_person_followers = ExternalPerson.joins(:owned_circles).merge(circles).uniq | |
7 | + | |
8 | + person_followers + external_person_followers | |
9 | + end | |
10 | + | |
11 | + def followed_by?(person) | |
12 | + (person == self) || (person.in? self.followers) | |
13 | + end | |
14 | + | |
15 | + def in_circle?(circle) | |
16 | + circle.in? self.circles | |
17 | + end | |
18 | +end | ... | ... |
app/models/concerns/follower.rb
... | ... | @@ -4,14 +4,14 @@ module Follower |
4 | 4 | def follow(profile, circles) |
5 | 5 | circles = [circles] unless circles.is_a?(Array) |
6 | 6 | circles.each do |new_circle| |
7 | - next if new_circle.owner != self || new_circle.profile_type != profile.class.name | |
7 | + next if new_circle.owner != self || !profile.kind_of?(new_circle.profile_type.constantize) | |
8 | 8 | ProfileFollower.create(profile: profile, circle: new_circle) |
9 | 9 | end |
10 | 10 | end |
11 | 11 | |
12 | 12 | def follows?(profile) |
13 | 13 | return false if profile.nil? |
14 | - p profile.followed_by?(self) | |
14 | + profile.followed_by?(self) | |
15 | 15 | end |
16 | 16 | |
17 | 17 | def unfollow(profile) |
... | ... | @@ -19,7 +19,10 @@ module Follower |
19 | 19 | end |
20 | 20 | |
21 | 21 | def followed_profiles |
22 | - Profile.followed_by self | |
22 | + external_people = ExternalPerson.joins(:circles).where("circles.owner_id = ?", self.id) | |
23 | + profiles = Profile.joins(:circles).where("circles.owner_id = ?", self.id) | |
24 | + | |
25 | + external_people.uniq + profiles.uniq | |
23 | 26 | end |
24 | 27 | |
25 | 28 | def update_profile_circles(profile, new_circles) |
... | ... | @@ -37,4 +40,8 @@ module Follower |
37 | 40 | ProfileFollower.with_profile(profile).with_circle(circle).destroy_all |
38 | 41 | end |
39 | 42 | |
43 | + def in_circle?(circle) | |
44 | + circle.in? self.circles | |
45 | + end | |
46 | + | |
40 | 47 | end | ... | ... |
app/models/external_person.rb
... | ... | @@ -4,9 +4,10 @@ class ExternalPerson < ActiveRecord::Base |
4 | 4 | include Human |
5 | 5 | include ProfileEntity |
6 | 6 | include Follower |
7 | + include Followable | |
7 | 8 | |
8 | - has_many :profile_followers | |
9 | - has_many :circles, :through => :profile_followers, :as => :profile | |
9 | + has_many :profile_followers, :as => :profile | |
10 | + has_many :circles, :through => :profile_followers | |
10 | 11 | has_many :owned_circles, as: :owner, :class_name => "Circle" |
11 | 12 | |
12 | 13 | validates_uniqueness_of :identifier, scope: :source |
... | ... | @@ -204,7 +205,7 @@ class ExternalPerson < ActiveRecord::Base |
204 | 205 | each_friend: nil, is_last_admin?: false, is_last_admin_leaving?: false, |
205 | 206 | leave: nil, last_notification: nil, notification_time: 0, notifier: nil, |
206 | 207 | remove_suggestion: nil, allow_invitation_from?: false, in_social_circle?: false, |
207 | - allow_followers: false, in_circles: Circle.none, followers: [], in_circle?: false | |
208 | + allow_followers: false | |
208 | 209 | } |
209 | 210 | |
210 | 211 | derivated_methods = generate_derivated_methods(methods_and_responses) |
... | ... | @@ -258,7 +259,7 @@ class ExternalPerson < ActiveRecord::Base |
258 | 259 | more_popular_label: _('no members'), profile_custom_image: nil, |
259 | 260 | is_on_homepage?: false, activities: ProfileActivity.none, |
260 | 261 | may_display_field_to?: true, may_display_location_to?: true, public_fields: |
261 | - {}, followed_by?: false, display_private_info_to?: true, can_view_field?: | |
262 | + {}, display_private_info_to?: true, can_view_field?: | |
262 | 263 | true, remove_from_suggestion_list: nil, layout_template: 'default', |
263 | 264 | is_admin?: false, add_friend: false, is_a_friend?: false, |
264 | 265 | already_request_friendship?: false, tracked_actions: ActionTracker::Record.none |
... | ... | @@ -275,6 +276,7 @@ class ExternalPerson < ActiveRecord::Base |
275 | 276 | if profile_instance_methods.keys.include? method |
276 | 277 | return profile_instance_methods[method] |
277 | 278 | end |
279 | + super | |
278 | 280 | end |
279 | 281 | |
280 | 282 | def respond_to_missing?(method_name, include_private = false) |
... | ... | @@ -283,6 +285,10 @@ class ExternalPerson < ActiveRecord::Base |
283 | 285 | super |
284 | 286 | end |
285 | 287 | |
288 | + def kind_of?(klass) | |
289 | + (klass == Person) ? true : super | |
290 | + end | |
291 | + | |
286 | 292 | private |
287 | 293 | |
288 | 294 | def generate_derivated_methods(methods) | ... | ... |
app/models/person.rb
app/models/profile.rb
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 | class Profile < ApplicationRecord |
5 | 5 | |
6 | 6 | include ProfileEntity |
7 | + include Followable | |
7 | 8 | |
8 | 9 | attr_accessible :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id, :lat, :lng, :is_template, :fields_privacy, :preferred_domain_id, :category_ids, :country, :city, :state, :national_region_code, :email, :contact_email, :redirect_l10n, :notification_time, |
9 | 10 | :custom_url_redirection, :email_suggestions, :allow_members_to_invite, :invite_friends_only, :secret, :profile_admin_mail_notification, :redirection_after_login, :allow_followers |
... | ... | @@ -219,13 +220,6 @@ class Profile < ApplicationRecord |
219 | 220 | scope :more_active, -> { order 'activities_count DESC' } |
220 | 221 | scope :more_recent, -> { order "created_at DESC" } |
221 | 222 | |
222 | - scope :followed_by, -> person{ | |
223 | - distinct.select('profiles.*'). | |
224 | - joins('left join profiles_circles ON profiles_circles.profile_id = profiles.id'). | |
225 | - joins('left join circles ON circles.id = profiles_circles.circle_id'). | |
226 | - where('circles.owner_id = ?', person.id) | |
227 | - } | |
228 | - | |
229 | 223 | settings_items :allow_followers, :type => :boolean, :default => true |
230 | 224 | alias_method :allow_followers?, :allow_followers |
231 | 225 | |
... | ... | @@ -241,15 +235,8 @@ class Profile < ApplicationRecord |
241 | 235 | |
242 | 236 | has_many :email_templates, :foreign_key => :owner_id |
243 | 237 | |
244 | - has_many :profile_followers | |
245 | - has_many :circles, :through => :profile_followers, :as => :profile | |
246 | - | |
247 | - def followers | |
248 | - person_followers = Person.joins(:owned_circles).merge(circles).uniq | |
249 | - external_person_followers = ExternalPerson.joins(:owned_circles).merge(circles).uniq | |
250 | - | |
251 | - person_followers + external_person_followers | |
252 | - end | |
238 | + has_many :profile_followers, :as => :profile | |
239 | + has_many :circles, :through => :profile_followers | |
253 | 240 | |
254 | 241 | # has_many :followers, -> { uniq }, :through => :profile_followers, :source => :person |
255 | 242 | |
... | ... | @@ -1010,10 +997,6 @@ private :generate_url, :url_options |
1010 | 997 | self.active_fields |
1011 | 998 | end |
1012 | 999 | |
1013 | - def followed_by?(person) | |
1014 | - (person == self) || (person.in? self.followers) | |
1015 | - end | |
1016 | - | |
1017 | 1000 | def in_social_circle?(person) |
1018 | 1001 | (person == self) || (person.is_member_of?(self)) |
1019 | 1002 | end |
... | ... | @@ -1057,7 +1040,4 @@ private :generate_url, :url_options |
1057 | 1040 | person.kind_of?(Profile) && person.has_permission?('destroy_profile', self) |
1058 | 1041 | end |
1059 | 1042 | |
1060 | - def in_circle?(circle) | |
1061 | - circle.in? self.circles | |
1062 | - end | |
1063 | 1043 | end | ... | ... |
db/schema.rb
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | # |
12 | 12 | # It's strongly recommended that you check this file into your version control system. |
13 | 13 | |
14 | -ActiveRecord::Schema.define(version: 20160608123748) do | |
14 | +ActiveRecord::Schema.define(version: 20160822184703) do | |
15 | 15 | |
16 | 16 | # These are extensions that must be enabled in order to support this database |
17 | 17 | enable_extension "plpgsql" |
... | ... | @@ -277,11 +277,13 @@ ActiveRecord::Schema.define(version: 20160608123748) do |
277 | 277 | |
278 | 278 | create_table "circles", force: :cascade do |t| |
279 | 279 | t.string "name" |
280 | - t.integer "person_id" | |
281 | - t.string "profile_type", null: false | |
280 | + t.integer "owner_id" | |
281 | + t.string "profile_type", null: false | |
282 | + t.string "owner_type", default: "Person" | |
282 | 283 | end |
283 | 284 | |
284 | - add_index "circles", ["person_id", "name"], name: "circles_composite_key_index", unique: true, using: :btree | |
285 | + add_index "circles", ["owner_id", "name"], name: "circles_composite_key_index", unique: true, using: :btree | |
286 | + add_index "circles", ["owner_id", "owner_type"], name: "index_circles_on_owner_id_and_owner_type", using: :btree | |
285 | 287 | |
286 | 288 | create_table "comments", force: :cascade do |t| |
287 | 289 | t.string "title" |
... | ... | @@ -553,6 +555,11 @@ ActiveRecord::Schema.define(version: 20160608123748) do |
553 | 555 | t.datetime "updated_at" |
554 | 556 | end |
555 | 557 | |
558 | + create_table "private_scraps", force: :cascade do |t| | |
559 | + t.integer "person_id" | |
560 | + t.integer "scrap_id" | |
561 | + end | |
562 | + | |
556 | 563 | create_table "product_qualifiers", force: :cascade do |t| |
557 | 564 | t.integer "product_id" |
558 | 565 | t.integer "qualifier_id" |
... | ... | @@ -681,9 +688,11 @@ ActiveRecord::Schema.define(version: 20160608123748) do |
681 | 688 | t.integer "circle_id" |
682 | 689 | t.datetime "created_at" |
683 | 690 | t.datetime "updated_at" |
691 | + t.string "profile_type", default: "Person" | |
684 | 692 | end |
685 | 693 | |
686 | 694 | add_index "profiles_circles", ["profile_id", "circle_id"], name: "profiles_circles_composite_key_index", unique: true, using: :btree |
695 | + add_index "profiles_circles", ["profile_id", "profile_type"], name: "index_profiles_circles_on_profile_id_and_profile_type", using: :btree | |
687 | 696 | |
688 | 697 | create_table "qualifier_certifiers", force: :cascade do |t| |
689 | 698 | t.integer "qualifier_id" | ... | ... |
test/unit/article_test.rb
... | ... | @@ -1101,7 +1101,7 @@ class ArticleTest < ActiveSupport::TestCase |
1101 | 1101 | |
1102 | 1102 | should 'create notifications to followers when creating an article' do |
1103 | 1103 | friend = fast_create(Person) |
1104 | - circle = Circle.create!(:person=> friend, :name => "Zombies", :profile_type => 'Person') | |
1104 | + circle = Circle.create!(:owner=> friend, :name => "Zombies", :profile_type => 'Person') | |
1105 | 1105 | friend.follow(profile, circle) |
1106 | 1106 | Article.destroy_all |
1107 | 1107 | ActionTracker::Record.destroy_all |
... | ... | @@ -1115,7 +1115,7 @@ class ArticleTest < ActiveSupport::TestCase |
1115 | 1115 | |
1116 | 1116 | should 'create the notification to the follower when one follower has the notification and the other no' do |
1117 | 1117 | f1 = fast_create(Person) |
1118 | - circle = Circle.create!(:person=> f1, :name => "Zombies", :profile_type => 'Person') | |
1118 | + circle = Circle.create!(:owner=> f1, :name => "Zombies", :profile_type => 'Person') | |
1119 | 1119 | f1.follow(profile, circle) |
1120 | 1120 | |
1121 | 1121 | User.current = profile.user |
... | ... | @@ -1125,7 +1125,7 @@ class ArticleTest < ActiveSupport::TestCase |
1125 | 1125 | assert_equal 2, ActionTrackerNotification.where(action_tracker_id: article.activity.id).count |
1126 | 1126 | |
1127 | 1127 | f2 = fast_create(Person) |
1128 | - circle2 = Circle.create!(:person=> f2, :name => "Zombies", :profile_type => 'Person') | |
1128 | + circle2 = Circle.create!(:owner=> f2, :name => "Zombies", :profile_type => 'Person') | |
1129 | 1129 | f2.follow(profile, circle2) |
1130 | 1130 | |
1131 | 1131 | article2 = create TinyMceArticle, :name => 'Tracked Article 2', :profile_id => profile.id |
... | ... | @@ -1137,7 +1137,7 @@ class ArticleTest < ActiveSupport::TestCase |
1137 | 1137 | should 'destroy activity and notifications of followers when destroying an article' do |
1138 | 1138 | friend = fast_create(Person) |
1139 | 1139 | |
1140 | - circle = Circle.create!(:person=> friend, :name => "Zombies", :profile_type => 'Person') | |
1140 | + circle = Circle.create!(:owner=> friend, :name => "Zombies", :profile_type => 'Person') | |
1141 | 1141 | |
1142 | 1142 | friend.follow(profile, circle) |
1143 | 1143 | ... | ... |
test/unit/follower_test.rb
... | ... | @@ -8,6 +8,7 @@ class FollowerTest < ActiveSupport::TestCase |
8 | 8 | |
9 | 9 | @circle1 = Circle.create!(owner: @person1, name: "Zombies", profile_type: 'Person') |
10 | 10 | @circle2 = Circle.create!(owner: @person1, name: "Humans", profile_type: 'Person') |
11 | + @circle3 = Circle.create!(owner: @person1, name: "Crypt", profile_type: 'Community') | |
11 | 12 | |
12 | 13 | @external_person = ExternalPerson.create!(identifier: 'johnlocke', |
13 | 14 | name: 'John Locke', |
... | ... | @@ -85,27 +86,32 @@ class FollowerTest < ActiveSupport::TestCase |
85 | 86 | |
86 | 87 | should 'get the followed profiles for a regular user' do |
87 | 88 | person3 = create_user('person-test-3').person |
89 | + community = fast_create(Community) | |
88 | 90 | |
89 | 91 | @person1.follow(@person2, @circle1) |
90 | 92 | @person1.follow(person3, @circle1) |
91 | - assert_equivalent [@person2, person3], @person1.followed_profiles | |
93 | + @person1.follow(community, @circle3) | |
94 | + assert_equivalent [@person2, person3, community], @person1.followed_profiles | |
92 | 95 | end |
93 | 96 | |
94 | 97 | should 'get the followed profiles for an external user' do |
95 | 98 | person3 = create_user('person-test-3').person |
99 | + community = fast_create(Community) | |
96 | 100 | @circle1.update_attributes(owner: @external_person) |
101 | + @circle3.update_attributes(owner: @external_person) | |
97 | 102 | |
98 | 103 | @external_person.follow(@person2, @circle1) |
99 | 104 | @external_person.follow(person3, @circle1) |
100 | - assert_equivalent [@person2, person3], @external_person.followed_profiles | |
105 | + @external_person.follow(community, @circle3) | |
106 | + assert_equivalent [@person2, person3, community], @external_person.followed_profiles | |
101 | 107 | end |
102 | 108 | |
103 | 109 | should 'not follow same person twice even with different circles' do |
104 | - circle3 = Circle.create!(owner: @person1, name: "Free Folk", profile_type: 'Person') | |
110 | + circle4 = Circle.create!(owner: @person1, name: "Free Folk", profile_type: 'Person') | |
105 | 111 | |
106 | 112 | @person1.follow(@person2, @circle1) |
107 | 113 | @person1.follow(@person2, @circle2) |
108 | - @person1.follow(@person2, circle3) | |
114 | + @person1.follow(@person2, circle4) | |
109 | 115 | assert_equivalent [@person2], @person1.followed_profiles |
110 | 116 | end |
111 | 117 | |
... | ... | @@ -118,21 +124,21 @@ class FollowerTest < ActiveSupport::TestCase |
118 | 124 | end |
119 | 125 | |
120 | 126 | should 'update profile circles for a person' do |
121 | - circle3 = Circle.create!(owner: @person1, name: "Brains", profile_type: 'Person') | |
127 | + circle4 = Circle.create!(owner: @person1, name: "Brains", profile_type: 'Person') | |
122 | 128 | @person1.follow(@person2, [@circle1, @circle2]) |
123 | 129 | |
124 | - @person1.update_profile_circles(@person2, [@circle2, circle3]) | |
125 | - assert_equivalent [@circle2, circle3], @person2.circles | |
130 | + @person1.update_profile_circles(@person2, [@circle2, circle4]) | |
131 | + assert_equivalent [@circle2, circle4], @person2.circles | |
126 | 132 | end |
127 | 133 | |
128 | 134 | should 'keep other follower circles after update' do |
129 | 135 | person3 = create_user('person-test-3').person |
130 | - circle3 = Circle.create!(owner: person3, name: "Humans", profile_type: 'Person') | |
136 | + circle4 = Circle.create!(owner: person3, name: "Humans", profile_type: 'Person') | |
131 | 137 | @person1.follow(@person2, @circle1) |
132 | - person3.follow(@person2, circle3) | |
138 | + person3.follow(@person2, circle4) | |
133 | 139 | |
134 | 140 | @person1.update_profile_circles(@person2, [@circle1, @circle2]) |
135 | - assert_equivalent [@circle1, @circle2, circle3], @person2.circles | |
141 | + assert_equivalent [@circle1, @circle2, circle4], @person2.circles | |
136 | 142 | end |
137 | 143 | |
138 | 144 | should 'remove a person from a circle' do |
... | ... | @@ -150,14 +156,10 @@ class FollowerTest < ActiveSupport::TestCase |
150 | 156 | assert_equivalent [@circle1, @circle2], @person2.circles |
151 | 157 | end |
152 | 158 | |
153 | - should 'external person be followable' do | |
154 | - person = fast_create(Person, :environment_id => Environment.default.id) | |
155 | - circle = Circle.create(owner: @external_person, profile_type: "Person", name: "FRIENDSSS") | |
156 | - pf = ProfileFollower.create(profile: @external_person, circle: circle) | |
157 | - assert person.follows? @external_person | |
158 | - | |
159 | - # assert_difference 'ProfileFollower.all.count' do | |
160 | - # person.follow(@external_person, circle) | |
161 | - # end | |
159 | + should 'follow External Person' do | |
160 | + assert_difference 'ProfileFollower.count' do | |
161 | + @person1.follow(@external_person, @circle1) | |
162 | + end | |
163 | + assert @person1.follows? @external_person | |
162 | 164 | end |
163 | 165 | end | ... | ... |
test/unit/friendship_test.rb
... | ... | @@ -115,8 +115,8 @@ class FriendshipTest < ActiveSupport::TestCase |
115 | 115 | p1 = create_user('testuser1').person |
116 | 116 | p2 = create_user('testuser2').person |
117 | 117 | |
118 | - circle1 = Circle.create!(:person=> p1, :name => "Zombies", :profile_type => 'Person') | |
119 | - circle2 = Circle.create!(:person=> p2, :name => "Zombies", :profile_type => 'Person') | |
118 | + circle1 = Circle.create!(:owner=> p1, :name => "Zombies", :profile_type => 'Person') | |
119 | + circle2 = Circle.create!(:owner=> p2, :name => "Zombies", :profile_type => 'Person') | |
120 | 120 | p1.follow(p2, circle1) |
121 | 121 | p2.follow(p1, circle2) |
122 | 122 | ... | ... |
test/unit/notify_activity_to_profiles_job_test.rb
... | ... | @@ -31,9 +31,9 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase |
31 | 31 | refute NotifyActivityToProfilesJob::NOTIFY_ONLY_COMMUNITY.include?(action_tracker.verb) |
32 | 32 | p1, p2, m1, m2 = fast_create(Person), fast_create(Person), fast_create(Person), fast_create(Person) |
33 | 33 | |
34 | - circle1 = Circle.create!(:person=> p1, :name => "Zombies", :profile_type => 'Person') | |
35 | - circle2 = Circle.create!(:person=> p2, :name => "Zombies", :profile_type => 'Person') | |
36 | - circle = Circle.create!(:person=> person, :name => "Zombies", :profile_type => 'Person') | |
34 | + circle1 = Circle.create!(:owner=> p1, :name => "Zombies", :profile_type => 'Person') | |
35 | + circle2 = Circle.create!(:owner=> p2, :name => "Zombies", :profile_type => 'Person') | |
36 | + circle = Circle.create!(:owner=> person, :name => "Zombies", :profile_type => 'Person') | |
37 | 37 | |
38 | 38 | fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle1.id) |
39 | 39 | fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle2.id) |
... | ... | @@ -79,7 +79,7 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase |
79 | 79 | refute NotifyActivityToProfilesJob::NOTIFY_ONLY_COMMUNITY.include?(action_tracker.verb) |
80 | 80 | p1, p2, m1, m2 = fast_create(Person), fast_create(Person), fast_create(Person), fast_create(Person) |
81 | 81 | |
82 | - circle1 = Circle.create!(:person=> p1, :name => "Zombies", :profile_type => 'Person') | |
82 | + circle1 = Circle.create!(:owner=> p1, :name => "Zombies", :profile_type => 'Person') | |
83 | 83 | fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle1.id) |
84 | 84 | |
85 | 85 | fast_create(RoleAssignment, :accessor_id => m1.id, :role_id => 3, :resource_id => community.id) |
... | ... | @@ -127,8 +127,8 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase |
127 | 127 | refute NotifyActivityToProfilesJob::NOTIFY_ONLY_COMMUNITY.include?(action_tracker.verb) |
128 | 128 | p1, p2, m1, m2 = fast_create(Person), fast_create(Person), fast_create(Person), fast_create(Person) |
129 | 129 | |
130 | - circle1 = Circle.create!(:person=> p1, :name => "Zombies", :profile_type => 'Person') | |
131 | - circle2 = Circle.create!(:person=> p2, :name => "Zombies", :profile_type => 'Person') | |
130 | + circle1 = Circle.create!(:owner=> p1, :name => "Zombies", :profile_type => 'Person') | |
131 | + circle2 = Circle.create!(:owner=> p2, :name => "Zombies", :profile_type => 'Person') | |
132 | 132 | |
133 | 133 | fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle1.id) |
134 | 134 | fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle2.id) | ... | ... |
test/unit/organization_test.rb
... | ... | @@ -267,9 +267,9 @@ class OrganizationTest < ActiveSupport::TestCase |
267 | 267 | o.add_member(p3) |
268 | 268 | assert p3.is_member_of?(o) |
269 | 269 | |
270 | - assert_equal true, o.send(:followed_by?,p1) | |
271 | - assert_equal true, o.send(:followed_by?,p3) | |
272 | - assert_equal false, o.send(:followed_by?,p2) | |
270 | + assert o.followed_by? p1 | |
271 | + assert o.followed_by? p3 | |
272 | + refute o.followed_by? p2 | |
273 | 273 | end |
274 | 274 | |
275 | 275 | should "compose bare jabber id by identifier plus 'conference' and default hostname" do | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -2249,30 +2249,4 @@ class ProfileTest < ActiveSupport::TestCase |
2249 | 2249 | assert_equivalent person3.followers, [person1, person2] |
2250 | 2250 | end |
2251 | 2251 | |
2252 | - should 'return all profiles followed by a regular person' do | |
2253 | - person1 = create_user('testperson-1').person | |
2254 | - person2 = create_user('testperson-2').person | |
2255 | - community = fast_create(Community) | |
2256 | - circle1 = Circle.create!(:owner => person1, :name => "Night's Watch", :profile_type => 'Person') | |
2257 | - circle2 = Circle.create!(:owner => person1, :name => "Free Folk", :profile_type => 'Community') | |
2258 | - | |
2259 | - person1.follow(person2, circle1) | |
2260 | - person1.follow(community, circle2) | |
2261 | - assert_equivalent [person2, community], Profile.followed_by(person1) | |
2262 | - end | |
2263 | - | |
2264 | - should 'return all profiles followed by an external person' do | |
2265 | - external_person = ExternalPerson.create!(identifier: 'johnlocke', name: 'John Locke', | |
2266 | - source: 'anerenvironment.org', email: 'locke@island.org', | |
2267 | - created_at: Date.yesterday) | |
2268 | - person = create_user('testperson-2').person | |
2269 | - community = fast_create(Community) | |
2270 | - circle1 = Circle.create!(:owner => external_person, :name => "Night's Watch", :profile_type => 'Person') | |
2271 | - circle2 = Circle.create!(:owner => external_person, :name => "Free Folk", :profile_type => 'Community') | |
2272 | - | |
2273 | - external_person.follow(person, circle1) | |
2274 | - external_person.follow(community, circle2) | |
2275 | - assert_equivalent [person, community], Profile.followed_by(external_person) | |
2276 | - end | |
2277 | - | |
2278 | 2252 | end | ... | ... |