Commit cf006cc397267e75365bf45c1e6f2a6eceaa0b37
1 parent
267d8d18
Exists in
master
and in
28 other branches
ActionItem36: putting friends in the right groups
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1498 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
16 additions
and
2 deletions
Show diff stats
app/models/add_friend.rb
@@ -11,8 +11,8 @@ class AddFriend < Task | @@ -11,8 +11,8 @@ class AddFriend < Task | ||
11 | alias :friend= :target= | 11 | alias :friend= :target= |
12 | 12 | ||
13 | def perform | 13 | def perform |
14 | - Friendship.create!(:person => requestor, :friend => target) | ||
15 | - Friendship.create!(:person => target, :friend => requestor) | 14 | + Friendship.create!(:person => requestor, :friend => target, :group => group_for_person) |
15 | + Friendship.create!(:person => target, :friend => requestor, :group => group_for_friend) | ||
16 | end | 16 | end |
17 | 17 | ||
18 | # Returns <tt>false</tt>. Adding friends by itself does not trigger e-mail | 18 | # Returns <tt>false</tt>. Adding friends by itself does not trigger e-mail |
test/unit/add_friend_test.rb
@@ -20,6 +20,20 @@ class AddFriendTest < ActiveSupport::TestCase | @@ -20,6 +20,20 @@ class AddFriendTest < ActiveSupport::TestCase | ||
20 | ok('p2 should have p1 as friend') { p2.friends.include?(p1) } | 20 | ok('p2 should have p1 as friend') { p2.friends.include?(p1) } |
21 | end | 21 | end |
22 | 22 | ||
23 | + should 'put friendships in the right groups' do | ||
24 | + p1 = create_user('testuser1').person | ||
25 | + p2 = create_user('testuser2').person | ||
26 | + | ||
27 | + task = AddFriend.create!(:person => p1, :group_for_person => 'friend1', :friend => p2, :group_for_friend => 'friend2') | ||
28 | + | ||
29 | + assert_difference Friendship, :count, 2 do | ||
30 | + task.finish | ||
31 | + end | ||
32 | + | ||
33 | + ok('p1 should list p2 as friend1') { p1.friendships.first.group == 'friend1' } | ||
34 | + ok('p2 should have p1 as friend2') { p2.friendships.first.group == 'friend2' } | ||
35 | + end | ||
36 | + | ||
23 | should 'require requestor (person adding other as friend)' do | 37 | should 'require requestor (person adding other as friend)' do |
24 | task = AddFriend.new | 38 | task = AddFriend.new |
25 | task.valid? | 39 | task.valid? |