Commit 4bd91b76a69042a6303ece4bb7776caadc6171a0

Authored by AntonioTerceiro
1 parent cf006cc3

ActionItem36: giving a default list of groups


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1499 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing 2 changed files with 10 additions and 5 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 friend_groups
9   - friendships.map {|item| item.group}.uniq
  9 + ([_('friends'), _('work'), _('school'), _('family')] + friendships.map {|item| item.group}).uniq
10 10 end
11 11  
12 12 # has_many :person_friendships
... ...
test/unit/person_test.rb
... ... @@ -158,17 +158,22 @@ class PersonTest < Test::Unit::TestCase
158 158  
159 159 end
160 160  
  161 + should 'provide default friend groups list' do
  162 + assert_equivalent [ 'friends', 'work', 'school', 'family' ], Person.new.friend_groups
  163 + end
  164 +
161 165 should 'list friend groups' do
162 166 p1 = create_user('testuser1').person
163 167 p2 = create_user('testuser2').person
164 168 p3 = create_user('testuser3').person
165 169 p4 = create_user('testuser4').person
166 170  
167   - Friendship.create!(:person => p1, :friend => p2, :group => 'family')
168   - Friendship.create!(:person => p1, :friend => p3, :group => 'school')
169   - Friendship.create!(:person => p1, :friend => p4, :group => 'school')
  171 + Friendship.create!(:person => p1, :friend => p2, :group => 'group1')
  172 + Friendship.create!(:person => p1, :friend => p3, :group => 'group2')
  173 + Friendship.create!(:person => p1, :friend => p4, :group => 'group1')
170 174  
171   - assert_equivalent ['family', 'school'], p1.friend_groups
  175 + assert_includes p1.friend_groups, 'group1'
  176 + assert_includes p1.friend_groups, 'group2'
172 177 end
173 178  
174 179 end
... ...