Commit 9bd039cabb0f4721d2239bd900f380ec4b96f437
1 parent
d1784d08
Exists in
master
and in
29 other branches
ActionItem172: adding admins to a profile
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1548 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
14 additions
and
0 deletions
Show diff stats
app/models/profile.rb
... | ... | @@ -275,4 +275,9 @@ class Profile < ActiveRecord::Base |
275 | 275 | self.affiliate(person, Profile::Roles.member) |
276 | 276 | end |
277 | 277 | |
278 | + # adds a person as administrator os this profile | |
279 | + def add_admin(person) | |
280 | + self.affiliate(person, Profile::Roles.admin) | |
281 | + end | |
282 | + | |
278 | 283 | end | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -337,6 +337,15 @@ class ProfileTest < Test::Unit::TestCase |
337 | 337 | assert c.members.include?(p), "Profile should add the new member" |
338 | 338 | end |
339 | 339 | |
340 | + should 'allow to add administrators' do | |
341 | + c = Profile.create!(:name => 'my test profile', :identifier => 'mytestprofile') | |
342 | + p = create_user('mytestuser').person | |
343 | + | |
344 | + c.add_admin(p) | |
345 | + | |
346 | + assert c.members.include?(p), "Profile should add the new admin" | |
347 | + end | |
348 | + | |
340 | 349 | should 'have tasks' do |
341 | 350 | c = Profile.create!(:name => 'my test profile', :identifier => 'mytestprofile') |
342 | 351 | t1 = c.tasks.build | ... | ... |