Commit 306e49b89a39292faa693ba65577c7d9ced0fdbc
1 parent
2519b304
Exists in
master
and in
22 other branches
ActionItem384: member leave from community/enterprise
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1782 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
8 additions
and
3 deletions
Show diff stats
test/functional/memberships_controller_test.rb
@@ -122,6 +122,7 @@ class MembershipsControllerTest < Test::Unit::TestCase | @@ -122,6 +122,7 @@ class MembershipsControllerTest < Test::Unit::TestCase | ||
122 | 122 | ||
123 | should 'present confirmation before leaving a profile' do | 123 | should 'present confirmation before leaving a profile' do |
124 | community = Community.create!(:name => 'my test community') | 124 | community = Community.create!(:name => 'my test community') |
125 | + community.add_member(profile) | ||
125 | get :leave, :profile => profile.identifier, :id => community.id | 126 | get :leave, :profile => profile.identifier, :id => community.id |
126 | 127 | ||
127 | assert_response :success | 128 | assert_response :success |
@@ -130,13 +131,15 @@ class MembershipsControllerTest < Test::Unit::TestCase | @@ -130,13 +131,15 @@ class MembershipsControllerTest < Test::Unit::TestCase | ||
130 | 131 | ||
131 | should 'actually leave profile' do | 132 | should 'actually leave profile' do |
132 | community = Community.create!(:name => 'my test community') | 133 | community = Community.create!(:name => 'my test community') |
134 | + community.add_member(profile) | ||
135 | + assert_includes profile.memberships, community | ||
133 | post :leave, :profile => profile.identifier, :id => community.id, :confirmation => '1' | 136 | post :leave, :profile => profile.identifier, :id => community.id, :confirmation => '1' |
134 | 137 | ||
135 | assert_response :redirect | 138 | assert_response :redirect |
136 | assert_redirected_to :action => 'index' | 139 | assert_redirected_to :action => 'index' |
137 | 140 | ||
138 | profile.reload | 141 | profile.reload |
139 | - assert !profile.memberships.include?(community) | 142 | + assert_not_includes profile.memberships, community |
140 | end | 143 | end |
141 | 144 | ||
142 | end | 145 | end |
test/unit/profile_test.rb
@@ -461,8 +461,10 @@ class ProfileTest < Test::Unit::TestCase | @@ -461,8 +461,10 @@ class ProfileTest < Test::Unit::TestCase | ||
461 | p = create_user('myothertestuser').person | 461 | p = create_user('myothertestuser').person |
462 | 462 | ||
463 | c.add_member(p) | 463 | c.add_member(p) |
464 | + assert_includes c.members, p | ||
464 | c.remove_member(p) | 465 | c.remove_member(p) |
465 | - assert !c.members.include?(p) | 466 | + c.reload |
467 | + assert_not_includes c.members, p | ||
466 | end | 468 | end |
467 | 469 | ||
468 | private | 470 | private |
vendor/plugins/access_control/lib/acts_as_accessible.rb
@@ -21,7 +21,7 @@ class ActiveRecord::Base | @@ -21,7 +21,7 @@ class ActiveRecord::Base | ||
21 | 21 | ||
22 | def disaffiliate(accessor, roles) | 22 | def disaffiliate(accessor, roles) |
23 | roles = [roles] unless roles.kind_of?(Array) | 23 | roles = [roles] unless roles.kind_of?(Array) |
24 | - roles.map {|role| accessor.remove_role(role, self)}.any? | 24 | + role_assignments.map{|ra|ra.destroy if roles.include?(ra.role) && ra.accessor == accessor} |
25 | end | 25 | end |
26 | 26 | ||
27 | def members | 27 | def members |