diff --git a/app/models/profile.rb b/app/models/profile.rb index c2b5cf6..33dd4a7 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -374,7 +374,7 @@ class Profile < ActiveRecord::Base end def remove_member(person) - self.disaffiliate(person, Profile::Roles.member) + self.disaffiliate(person, Profile::Roles.all_roles) end # adds a person as administrator os this profile diff --git a/test/functional/memberships_controller_test.rb b/test/functional/memberships_controller_test.rb index b5c2d76..f2fae80 100644 --- a/test/functional/memberships_controller_test.rb +++ b/test/functional/memberships_controller_test.rb @@ -233,4 +233,13 @@ class MembershipsControllerTest < Test::Unit::TestCase assert_equal 1, assigns(:community).boxes[0].blocks.size end + should 'leave community' do + community = Community.create!(:name =>'Boca do Siri', :identifier => 'boca_do_siri') + community.affiliate(profile, Profile::Roles.all_roles) + post :leave, :profile => profile.identifier, :id => community.id, :confirmation => true + + profile.reload + assert_not_includes profile.memberships, community + end + end diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index bf80987..10d2235 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -810,6 +810,17 @@ class ProfileTest < Test::Unit::TestCase assert !p2.articles.find(:first, :conditions => {:public_article => false}) end + should 'remove member with many roles' do + person = create_user('test_user').person + community = Community.create!(:name => 'Boca do Siri', :identifier => 'boca_do_siri') + community.affiliate(person, Profile::Roles.all_roles) + + community.remove_member(person) + + person.reload + assert_not_includes person.memberships, community + end + should 'copy set of articles from a template' do template = create_user('test_template').person template.articles.destroy_all @@ -842,6 +853,7 @@ class ProfileTest < Test::Unit::TestCase assert_equal 1, p.boxes.size assert_equal 1, p.boxes[0].blocks.size end + private def assert_invalid_identifier(id) -- libgit2 0.21.2