Commit 2f2e61e0cce332572f56d6550210c0440d397759
1 parent
f03d3563
Exists in
master
and in
23 other branches
ActionItem36: listing friends
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1468 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
12 additions
and
1 deletions
Show diff stats
app/controllers/my_profile/friends_controller.rb
| 1 | class FriendsController < MyProfileController | 1 | class FriendsController < MyProfileController |
| 2 | + | ||
| 3 | + def index | ||
| 4 | + @friends = profile.friends | ||
| 5 | + end | ||
| 2 | 6 | ||
| 3 | def add | 7 | def add |
| 4 | @friend = Person.find(params[:id]) | 8 | @friend = Person.find(params[:id]) |
| 5 | if request.post? && params[:confirmation] | 9 | if request.post? && params[:confirmation] |
| 6 | - AddFriend.create!(:person => user, :friend => @friend) | 10 | + AddFriend.create!(:person => profile, :friend => @friend) |
| 7 | 11 | ||
| 8 | # FIXME shouldn't redirect to the friend's page? | 12 | # FIXME shouldn't redirect to the friend's page? |
| 9 | redirect_to :action => 'index' | 13 | redirect_to :action => 'index' |
test/functional/friends_controller_test.rb
| @@ -21,6 +21,13 @@ class FriendsControllerTest < Test::Unit::TestCase | @@ -21,6 +21,13 @@ class FriendsControllerTest < Test::Unit::TestCase | ||
| 21 | end | 21 | end |
| 22 | attr_accessor :profile, :friend | 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 | should 'confirm addition of new friend' do | 31 | should 'confirm addition of new friend' do |
| 25 | get :add, :id => friend.id | 32 | get :add, :id => friend.id |
| 26 | 33 |