Commit 2f2e61e0cce332572f56d6550210c0440d397759

Authored by AntonioTerceiro
1 parent f03d3563

ActionItem36: listing friends


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1468 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/my_profile/friends_controller.rb
1 1 class FriendsController < MyProfileController
  2 +
  3 + def index
  4 + @friends = profile.friends
  5 + end
2 6  
3 7 def add
4 8 @friend = Person.find(params[:id])
5 9 if request.post? && params[:confirmation]
6   - AddFriend.create!(:person => user, :friend => @friend)
  10 + AddFriend.create!(:person => profile, :friend => @friend)
7 11  
8 12 # FIXME shouldn't redirect to the friend's page?
9 13 redirect_to :action => 'index'
... ...
test/functional/friends_controller_test.rb
... ... @@ -21,6 +21,13 @@ class FriendsControllerTest &lt; Test::Unit::TestCase
21 21 end
22 22 attr_accessor :profile, :friend
23 23  
  24 + should 'list friends' do
  25 + get :index
  26 + assert_response :success
  27 + assert_template 'index'
  28 + assert_kind_of Array, assigns(:friends)
  29 + end
  30 +
24 31 should 'confirm addition of new friend' do
25 32 get :add, :id => friend.id
26 33  
... ...