Commit 8c4e4f4bdd1f1c6d9b9c6b717962b6274e7223d0

Authored by Larissa Reis
1 parent 06cb2c65

invite-members: refactor cancelation of invitations after membership

  Refactor commit 737f856ef88a810583886ab402e1267e098c54d8.

(ActionItem3100)
app/models/invite_member.rb
@@ -13,7 +13,7 @@ class InviteMember < Invitation @@ -13,7 +13,7 @@ class InviteMember < Invitation
13 end 13 end
14 14
15 def perform 15 def perform
16 - community.add_member(friend) and friend.tasks.pending.of("InviteMember").select { |t| t.data[:community_id] == community_id }.each { |invite| invite.cancel } 16 + community.add_member(friend)
17 end 17 end
18 18
19 def title 19 def title
app/models/profile.rb
@@ -618,6 +618,7 @@ private :generate_url, :url_options @@ -618,6 +618,7 @@ private :generate_url, :url_options
618 self.affiliate(person, Profile::Roles.admin(environment.id)) if members_count == 0 618 self.affiliate(person, Profile::Roles.admin(environment.id)) if members_count == 0
619 self.affiliate(person, Profile::Roles.member(environment.id)) 619 self.affiliate(person, Profile::Roles.member(environment.id))
620 end 620 end
  621 + person.tasks.pending.of("InviteMember").select { |t| t.data[:community_id] == self.id }.each { |invite| invite.cancel }
621 else 622 else
622 raise _("%s can't have members") % self.class.name 623 raise _("%s can't have members") % self.class.name
623 end 624 end