Commit 6d5e63f5a647bf67b126eed49303470684d71771
1 parent
49568a03
Exists in
master
and in
29 other branches
Sends invitation to join community when user is already a friend
Invitations to join a community weren't creating a task when the user being invited was already a friend of the user inviting them, this fixes this issue.
Showing
2 changed files
with
24 additions
and
1 deletions
Show diff stats
app/models/invitation.rb
... | ... | @@ -64,7 +64,7 @@ class Invitation < Task |
64 | 64 | |
65 | 65 | task_args = if user.nil? |
66 | 66 | {:person => person, :friend_name => friend_name, :friend_email => friend_email, :message => message} |
67 | - elsif !user.person.is_a_friend?(person) | |
67 | + elsif !(user.person.is_a_friend?(person) && profile.person?) | |
68 | 68 | {:person => person, :target => user.person} |
69 | 69 | end |
70 | 70 | ... | ... |
test/unit/invitation_test.rb
... | ... | @@ -72,6 +72,29 @@ class InvitationTest < ActiveSupport::TestCase |
72 | 72 | end |
73 | 73 | end |
74 | 74 | |
75 | + should 'do nothing if the invited friend is already your friend' do | |
76 | + person = create_user('person').person | |
77 | + invited_friend = create_user('invited_friend').person | |
78 | + | |
79 | + invited_friend.add_friend(person) | |
80 | + | |
81 | + assert_no_difference InviteFriend, :count do | |
82 | + Invitation.invite( person, [invited_friend.user.email], "", person ) | |
83 | + end | |
84 | + end | |
85 | + | |
86 | + should 'and yet be able to invite friends to community' do | |
87 | + person = create_user('person').person | |
88 | + invited_friend = create_user('invited_friend').person | |
89 | + | |
90 | + invited_friend.add_friend(person) | |
91 | + community = fast_create(Community) | |
92 | + | |
93 | + assert_difference InviteMember, :count do | |
94 | + Invitation.invite( person, [invited_friend.user.email], "", community ) | |
95 | + end | |
96 | + end | |
97 | + | |
75 | 98 | should 'add url on message if user removed it' do |
76 | 99 | person = create_user('testuser1').person |
77 | 100 | friend = create_user('testuser2').person | ... | ... |