From 9bd039cabb0f4721d2239bd900f380ec4b96f437 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Sat, 1 Mar 2008 20:18:47 +0000 Subject: [PATCH] ActionItem172: adding admins to a profile --- app/models/profile.rb | 5 +++++ test/unit/profile_test.rb | 9 +++++++++ 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/app/models/profile.rb b/app/models/profile.rb index 9805748..764a38c 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -275,4 +275,9 @@ class Profile < ActiveRecord::Base self.affiliate(person, Profile::Roles.member) end + # adds a person as administrator os this profile + def add_admin(person) + self.affiliate(person, Profile::Roles.admin) + end + end diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index 2fa898d..95720dc 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -337,6 +337,15 @@ class ProfileTest < Test::Unit::TestCase assert c.members.include?(p), "Profile should add the new member" end + should 'allow to add administrators' do + c = Profile.create!(:name => 'my test profile', :identifier => 'mytestprofile') + p = create_user('mytestuser').person + + c.add_admin(p) + + assert c.members.include?(p), "Profile should add the new admin" + end + should 'have tasks' do c = Profile.create!(:name => 'my test profile', :identifier => 'mytestprofile') t1 = c.tasks.build -- libgit2 0.21.2