Commit 1bcdb1dc0045eaaa26fa7afc53f99db7d967bc11

Authored by AntonioTerceiro
1 parent 6f7fdaf9

ActionItem154: updating the block types used for profiles and environments


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1343 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/admin/environment_design_controller.rb
1 class EnvironmentDesignController < BoxOrganizerController 1 class EnvironmentDesignController < BoxOrganizerController
2 2
3 def available_blocks 3 def available_blocks
4 - @available_blocks ||= [ LoginBlock, EnvironmentStatisticsBlock, RecentDocumentsBlock ] 4 + @available_blocks ||= [ LoginBlock, EnvironmentStatisticsBlock, RecentDocumentsBlock, ProfileListBlock ]
5 end 5 end
6 6
7 end 7 end
app/controllers/my_profile/profile_design_controller.rb
@@ -3,7 +3,13 @@ class ProfileDesignController &lt; BoxOrganizerController @@ -3,7 +3,13 @@ class ProfileDesignController &lt; BoxOrganizerController
3 needs_profile 3 needs_profile
4 4
5 def available_blocks 5 def available_blocks
6 - @available_blocks ||= [ Block, ArticleBlock, TagsBlock, RecentDocumentsBlock, ProfileInfoBlock ] 6 + blocks = [ ArticleBlock, TagsBlock, RecentDocumentsBlock, ProfileInfoBlock, TagsBlock ]
  7 +
  8 + if profile.has_members?
  9 + blocks << MembersBlock
  10 + end
  11 +
  12 + blocks
7 end 13 end
8 14
9 end 15 end
test/functional/profile_design_controller_test.rb
@@ -150,12 +150,12 @@ class ProfileDesignControllerTest &lt; Test::Unit::TestCase @@ -150,12 +150,12 @@ class ProfileDesignControllerTest &lt; Test::Unit::TestCase
150 150
151 should 'actually add a new block' do 151 should 'actually add a new block' do
152 assert_difference Block, :count do 152 assert_difference Block, :count do
153 - post :add_block, :profile => 'ze', :box_id => 1, :type => Block.name 153 + post :add_block, :profile => 'ze', :box_id => 1, :type => RecentDocumentsBlock.name
154 assert_redirected_to :action => 'index' 154 assert_redirected_to :action => 'index'
155 end 155 end
156 end 156 end
157 157
158 - should 'not allow tp create unknown types' do 158 + should 'not allow to create unknown types' do
159 assert_no_difference Block, :count do 159 assert_no_difference Block, :count do
160 assert_raise ArgumentError do 160 assert_raise ArgumentError do
161 post :add_block, :profile => 'ze', :box_id => 1, :type => "PleaseLetMeCrackYourSite" 161 post :add_block, :profile => 'ze', :box_id => 1, :type => "PleaseLetMeCrackYourSite"