Commit 1b1445d782e64e5253e0175e601d5ca73af7543a

Authored by AntonioTerceiro
1 parent 78a070f6

ActionItem36: don't suggest duplicated friend groups


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1512 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing 2 changed files with 10 additions and 1 deletions   Show diff stats
app/models/person.rb
... ... @@ -6,7 +6,7 @@ class Person < Profile
6 6 has_many :friends, :class_name => 'Person', :through => :friendships
7 7  
8 8 def suggested_friend_groups
9   - friend_groups + [ _('friends'), _('work'), _('school'), _('family') ]
  9 + (friend_groups + [ _('friends'), _('work'), _('school'), _('family') ]).uniq
10 10 end
11 11  
12 12 def friend_groups
... ...
test/unit/person_test.rb
... ... @@ -182,4 +182,13 @@ class PersonTest < Test::Unit::TestCase
182 182 assert_equivalent ['group1', 'group2'], p1.friend_groups
183 183 end
184 184  
  185 + should 'not suggest duplicated friend groups' do
  186 + p1 = create_user('testuser1').person
  187 + p2 = create_user('testuser2').person
  188 +
  189 + p1.add_friend(p2, 'friends')
  190 +
  191 + assert_equal p1.suggested_friend_groups, p1.suggested_friend_groups.uniq
  192 + end
  193 +
185 194 end
... ...