Commit 18847bf430c0677003e31bde20bc2f0529a107a7

Authored by GrazienoPellegrino
1 parent fd265290

ActionItem589: E preciso sair duas vezes de um grupo quando se tem 2 papeis no grupo



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2415 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/profile.rb
... ... @@ -374,7 +374,7 @@ class Profile < ActiveRecord::Base
374 374 end
375 375  
376 376 def remove_member(person)
377   - self.disaffiliate(person, Profile::Roles.member)
  377 + self.disaffiliate(person, Profile::Roles.all_roles)
378 378 end
379 379  
380 380 # adds a person as administrator os this profile
... ...
test/functional/memberships_controller_test.rb
... ... @@ -233,4 +233,13 @@ class MembershipsControllerTest < Test::Unit::TestCase
233 233 assert_equal 1, assigns(:community).boxes[0].blocks.size
234 234 end
235 235  
  236 + should 'leave community' do
  237 + community = Community.create!(:name =>'Boca do Siri', :identifier => 'boca_do_siri')
  238 + community.affiliate(profile, Profile::Roles.all_roles)
  239 + post :leave, :profile => profile.identifier, :id => community.id, :confirmation => true
  240 +
  241 + profile.reload
  242 + assert_not_includes profile.memberships, community
  243 + end
  244 +
236 245 end
... ...
test/unit/profile_test.rb
... ... @@ -810,6 +810,17 @@ class ProfileTest < Test::Unit::TestCase
810 810 assert !p2.articles.find(:first, :conditions => {:public_article => false})
811 811 end
812 812  
  813 + should 'remove member with many roles' do
  814 + person = create_user('test_user').person
  815 + community = Community.create!(:name => 'Boca do Siri', :identifier => 'boca_do_siri')
  816 + community.affiliate(person, Profile::Roles.all_roles)
  817 +
  818 + community.remove_member(person)
  819 +
  820 + person.reload
  821 + assert_not_includes person.memberships, community
  822 + end
  823 +
813 824 should 'copy set of articles from a template' do
814 825 template = create_user('test_template').person
815 826 template.articles.destroy_all
... ... @@ -842,6 +853,7 @@ class ProfileTest < Test::Unit::TestCase
842 853 assert_equal 1, p.boxes.size
843 854 assert_equal 1, p.boxes[0].blocks.size
844 855 end
  856 +
845 857 private
846 858  
847 859 def assert_invalid_identifier(id)
... ...