From 030dc146b2827cabe2bd22482ffcf3e116d1caa8 Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Wed, 26 Aug 2009 19:05:06 -0300 Subject: [PATCH] ActionItem1224: not invite when is friend --- app/controllers/my_profile/friends_controller.rb | 6 +++--- test/functional/friends_controller_test.rb | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/my_profile/friends_controller.rb b/app/controllers/my_profile/friends_controller.rb index 15081f3..f452cfa 100644 --- a/app/controllers/my_profile/friends_controller.rb +++ b/app/controllers/my_profile/friends_controller.rb @@ -74,10 +74,10 @@ class FriendsController < MyProfileController end friend = User.find_by_email(friend_email) - if !friend.nil? && friend.person.person? - InviteFriend.create(:person => profile, :friend => friend.person) - else + if friend.nil? InviteFriend.create(:person => profile, :friend_name => friend_name, :friend_email => friend_email, :message => params[:message]) + elsif !friend.person.is_a_friend?(profile) + InviteFriend.create(:person => profile, :friend => friend.person) end end diff --git a/test/functional/friends_controller_test.rb b/test/functional/friends_controller_test.rb index 506c918..20988c4 100644 --- a/test/functional/friends_controller_test.rb +++ b/test/functional/friends_controller_test.rb @@ -157,4 +157,11 @@ class FriendsControllerTest < Test::Unit::TestCase end end + should 'not create InviteFriend if is a friend' do + friend = create_user('testfriend', :email => 'friend@noosfero.org') + friend.person.add_friend(profile) + assert_no_difference InviteFriend, :count do + post :invite, :manual_import_addresses => "#{friend.name} <#{friend.email}>", :import_from => "manual", :message => "click: ", :confirmation => 1, :wizard => true + end + end end -- libgit2 0.21.2