Commit 15f77ee32b2bf33ad7eb5db837ed92adf0f3a959

Authored by Larissa Reis
1 parent 88fd96e9

Correctly remove followers from circle when unfriend

Showing 1 changed file with 5 additions and 2 deletions   Show diff stats
app/models/friendship.rb
... ... @@ -20,8 +20,11 @@ class Friendship < ApplicationRecord
20 20 Friendship.update_cache_counter(:friends_count, friendship.person, -1)
21 21 Friendship.update_cache_counter(:friends_count, friendship.friend, -1)
22 22  
23   - circle = Circle.find_by(:person => friendship.person, :name => (friendship.group.blank? ? 'friendships': friendship.group) )
24   - friendship.person.remove_profile_from_circle(friendship.friend, circle) if circle
  23 + groups = friendship.group.blank? ? ['friendships'] : friendship.group.split(',').map(&:strip)
  24 + groups.each do |group|
  25 + circle = Circle.find_by(:person => friendship.person, :name => group )
  26 + friendship.person.remove_profile_from_circle(friendship.friend, circle) if circle
  27 + end
25 28 end
26 29  
27 30 def self.remove_friendship(person1, person2)
... ...