From 1f15609ca27213103cbde9405328e48489abeacc Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Fri, 15 Feb 2008 17:34:32 +0000 Subject: [PATCH] ActionItem42: refactoring: moving method up --- app/models/community.rb | 7 ------- app/models/profile.rb | 5 +++++ test/unit/community_test.rb | 9 --------- test/unit/profile_test.rb | 9 +++++++++ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/app/models/community.rb b/app/models/community.rb index 8865abb..421c214 100644 --- a/app/models/community.rb +++ b/app/models/community.rb @@ -7,11 +7,4 @@ class Community < Organization self.identifier = value.to_slug end - # FIXME should't this method be in Profile class? - # - # Adds a person as member of this Community (FIXME). - def add_member(person) - self.affiliate(person, Profile::Roles.member) - end - end diff --git a/app/models/profile.rb b/app/models/profile.rb index 6013e5a..7a15fb8 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -247,4 +247,9 @@ class Profile < ActiveRecord::Base feed.save! end + # Adds a person as member of this Profile. + def add_member(person) + self.affiliate(person, Profile::Roles.member) + end + end diff --git a/test/unit/community_test.rb b/test/unit/community_test.rb index 38d68bf..4472e44 100644 --- a/test/unit/community_test.rb +++ b/test/unit/community_test.rb @@ -18,15 +18,6 @@ class CommunityTest < Test::Unit::TestCase assert_equal 'the description of the community', c.description end - should 'allow to add new members' do - c = Community.create!(:name => 'my test community') - p = create_user('mytestuser').person - - c.add_member(p) - - assert c.members.include?(p), "Community should add the new member" - end - should 'create default set of blocks' do c = Community.create!(:name => 'my new community') diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index 9b471cf..ffef049 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -325,6 +325,15 @@ class ProfileTest < Test::Unit::TestCase assert_kind_of RssFeed, profile.articles.find_by_path('feed') end + should 'allow to add new members' do + c = Profile.create!(:name => 'my test profile', :identifier => 'mytestprofile') + p = create_user('mytestuser').person + + c.add_member(p) + + assert c.members.include?(p), "Profile should add the new member" + end + private -- libgit2 0.21.2