Commit 1f15609ca27213103cbde9405328e48489abeacc
1 parent
7403a597
Exists in
master
and in
29 other branches
ActionItem42: refactoring: moving method up
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1379 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
4 changed files
with
14 additions
and
16 deletions
Show diff stats
app/models/community.rb
@@ -7,11 +7,4 @@ class Community < Organization | @@ -7,11 +7,4 @@ class Community < Organization | ||
7 | self.identifier = value.to_slug | 7 | self.identifier = value.to_slug |
8 | end | 8 | end |
9 | 9 | ||
10 | - # FIXME should't this method be in Profile class? | ||
11 | - # | ||
12 | - # Adds a person as member of this Community (FIXME). | ||
13 | - def add_member(person) | ||
14 | - self.affiliate(person, Profile::Roles.member) | ||
15 | - end | ||
16 | - | ||
17 | end | 10 | end |
app/models/profile.rb
@@ -247,4 +247,9 @@ class Profile < ActiveRecord::Base | @@ -247,4 +247,9 @@ class Profile < ActiveRecord::Base | ||
247 | feed.save! | 247 | feed.save! |
248 | end | 248 | end |
249 | 249 | ||
250 | + # Adds a person as member of this Profile. | ||
251 | + def add_member(person) | ||
252 | + self.affiliate(person, Profile::Roles.member) | ||
253 | + end | ||
254 | + | ||
250 | end | 255 | end |
test/unit/community_test.rb
@@ -18,15 +18,6 @@ class CommunityTest < Test::Unit::TestCase | @@ -18,15 +18,6 @@ class CommunityTest < Test::Unit::TestCase | ||
18 | assert_equal 'the description of the community', c.description | 18 | assert_equal 'the description of the community', c.description |
19 | end | 19 | end |
20 | 20 | ||
21 | - should 'allow to add new members' do | ||
22 | - c = Community.create!(:name => 'my test community') | ||
23 | - p = create_user('mytestuser').person | ||
24 | - | ||
25 | - c.add_member(p) | ||
26 | - | ||
27 | - assert c.members.include?(p), "Community should add the new member" | ||
28 | - end | ||
29 | - | ||
30 | should 'create default set of blocks' do | 21 | should 'create default set of blocks' do |
31 | c = Community.create!(:name => 'my new community') | 22 | c = Community.create!(:name => 'my new community') |
32 | 23 |
test/unit/profile_test.rb
@@ -325,6 +325,15 @@ class ProfileTest < Test::Unit::TestCase | @@ -325,6 +325,15 @@ class ProfileTest < Test::Unit::TestCase | ||
325 | assert_kind_of RssFeed, profile.articles.find_by_path('feed') | 325 | assert_kind_of RssFeed, profile.articles.find_by_path('feed') |
326 | end | 326 | end |
327 | 327 | ||
328 | + should 'allow to add new members' do | ||
329 | + c = Profile.create!(:name => 'my test profile', :identifier => 'mytestprofile') | ||
330 | + p = create_user('mytestuser').person | ||
331 | + | ||
332 | + c.add_member(p) | ||
333 | + | ||
334 | + assert c.members.include?(p), "Profile should add the new member" | ||
335 | + end | ||
336 | + | ||
328 | 337 | ||
329 | private | 338 | private |
330 | 339 |