diff --git a/app/controllers/my_profile/profile_design_controller.rb b/app/controllers/my_profile/profile_design_controller.rb index ad666e2..e849ff0 100644 --- a/app/controllers/my_profile/profile_design_controller.rb +++ b/app/controllers/my_profile/profile_design_controller.rb @@ -37,6 +37,10 @@ class ProfileDesignController < BoxOrganizerController blocks << BlogArchivesBlock end + if user.is_admin?(profile.environment) + blocks << RawHTMLBlock + end + blocks end diff --git a/test/functional/profile_design_controller_test.rb b/test/functional/profile_design_controller_test.rb index 1d607e3..3f0cbfa 100644 --- a/test/functional/profile_design_controller_test.rb +++ b/test/functional/profile_design_controller_test.rb @@ -342,10 +342,12 @@ class ProfileDesignControllerTest < Test::Unit::TestCase profile.stubs(:person?).returns(true) profile.stubs(:enterprise?).returns(false) profile.stubs(:has_blog?).returns(false) + profile.stubs(:is_admin?).with(anything).returns(false) environment = mock profile.stubs(:environment).returns(environment) environment.stubs(:enabled?).returns(false) @controller.stubs(:profile).returns(profile) + @controller.stubs(:user).returns(profile) assert_equal PERSON_BLOCKS, @controller.available_blocks end @@ -355,10 +357,12 @@ class ProfileDesignControllerTest < Test::Unit::TestCase profile.stubs(:person?).returns(true) profile.stubs(:enterprise?).returns(false) profile.stubs(:has_blog?).returns(false) + profile.stubs(:is_admin?).with(anything).returns(false) environment = mock profile.stubs(:environment).returns(environment) environment.stubs(:enabled?).returns(false) @controller.stubs(:profile).returns(profile) + @controller.stubs(:user).returns(profile) assert_equal [], @controller.available_blocks - PERSON_BLOCKS_WITH_MEMBERS end @@ -368,10 +372,12 @@ class ProfileDesignControllerTest < Test::Unit::TestCase profile.stubs(:person?).returns(true) profile.stubs(:enterprise?).returns(false) profile.stubs(:has_blog?).returns(true) + profile.stubs(:is_admin?).with(anything).returns(false) environment = mock profile.stubs(:environment).returns(environment) environment.stubs(:enabled?).returns(false) @controller.stubs(:profile).returns(profile) + @controller.stubs(:user).returns(profile) assert_equal [], @controller.available_blocks - PERSON_BLOCKS_WITH_BLOG end @@ -381,10 +387,12 @@ class ProfileDesignControllerTest < Test::Unit::TestCase profile.stubs(:person?).returns(false) profile.stubs(:enterprise?).returns(true) profile.stubs(:has_blog?).returns(false) + profile.stubs(:is_admin?).with(anything).returns(false) environment = mock profile.stubs(:environment).returns(environment) environment.stubs(:enabled?).returns(true) @controller.stubs(:profile).returns(profile) + @controller.stubs(:user).returns(profile) assert_equal [], @controller.available_blocks - ENTERPRISE_BLOCKS end @@ -394,11 +402,27 @@ class ProfileDesignControllerTest < Test::Unit::TestCase profile.stubs(:person?).returns(false) profile.stubs(:enterprise?).returns(true) profile.stubs(:has_blog?).returns(false) + profile.stubs(:is_admin?).with(anything).returns(false) environment = mock profile.stubs(:environment).returns(environment) environment.stubs(:enabled?).returns(false) @controller.stubs(:profile).returns(profile) + @controller.stubs(:user).returns(profile) assert_equal [], @controller.available_blocks - ENTERPRISE_BLOCKS_WITH_PRODUCTS_ENABLE end + should 'allow admins to add RawHTMLBlock' do + profile.stubs(:is_admin?).with(anything).returns(true) + @controller.stubs(:user).returns(profile) + get :add_block, :profile => 'designtestuser' + assert_tag :tag => 'input', :attributes => { :id => 'type_rawhtmlblock', :value => 'RawHTMLBlock' } + end + + should 'not allow normal users to add RawHTMLBlock' do + profile.stubs(:is_admin?).with(anything).returns(false) + @controller.stubs(:user).returns(profile) + get :add_block, :profile => 'designtestuser' + assert_no_tag :tag => 'input', :attributes => { :id => 'type_rawhtmlblock', :value => 'RawHTMLBlock' } + end + end -- libgit2 0.21.2