Commit 5adefb332a9e93e2973d372a74172ad6016b294a
Committed by
Antonio Terceiro
1 parent
3045b20d
Exists in
master
and in
29 other branches
ActionItem1194: add_member task now handles "0" id roles
Showing
2 changed files
with
14 additions
and
1 deletions
Show diff stats
app/models/add_member.rb
... | ... | @@ -12,7 +12,7 @@ class AddMember < Task |
12 | 12 | |
13 | 13 | def perform |
14 | 14 | self.roles ||= [Profile::Roles.member(organization.environment.id).id] |
15 | - target.affiliate(requestor, self.roles.map{|i| Role.find(i)}) | |
15 | + target.affiliate(requestor, self.roles.select{|r| !r.to_i.zero? }.map{|i| Role.find(i)}) | |
16 | 16 | end |
17 | 17 | |
18 | 18 | def description | ... | ... |
test/unit/add_member_test.rb
... | ... | @@ -95,4 +95,17 @@ class AddMemberTest < ActiveSupport::TestCase |
95 | 95 | end |
96 | 96 | end |
97 | 97 | |
98 | + should 'ignore roles with id zero' do | |
99 | + p = create_user('testuser1').person | |
100 | + c = Community.create!(:name => 'community_test') | |
101 | + | |
102 | + role = Profile::Roles.member(c.environment.id) | |
103 | + TaskMailer.stubs(:deliver_target_notification) | |
104 | + task = AddMember.create!(:roles => ["0", role.id, nil], :person => p, :organization => c) | |
105 | + task.finish | |
106 | + | |
107 | + current_roles = p.find_roles(c).map(&:role) | |
108 | + assert_includes current_roles, role | |
109 | + end | |
110 | + | |
98 | 111 | end | ... | ... |