From 6d36bda8dfa8c30f96934098c880b73e87c6798c Mon Sep 17 00:00:00 2001 From: Moises Machado Date: Thu, 27 Aug 2009 17:46:58 -0300 Subject: [PATCH] ActionItem1209: users cannot create events when its disabled --- app/controllers/my_profile/cms_controller.rb | 4 ++-- test/functional/cms_controller_test.rb | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 96e5fac..0b27c0c 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -21,9 +21,9 @@ class CmsController < MyProfileController def available_article_types articles = [ TinyMceArticle, - TextileArticle, - Event + TextileArticle ] + articles << Event unless profile.environment.enabled?(:disable_asset_events) parent_id = params ? params[:parent_id] : nil if !parent_id or !Article.find(parent_id).blog? articles += [ diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index 62f10e7..42f6a63 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -560,12 +560,12 @@ class CmsControllerTest < Test::Unit::TestCase end should 'not make enterprise homepage available to person' do - @controller.stubs(:profile).returns(Person.new) + @controller.stubs(:profile).returns(create_user('test_user').person) assert_not_includes @controller.available_article_types, EnterpriseHomepage end should 'make enterprise homepage available to enterprises' do - @controller.stubs(:profile).returns(Enterprise.new) + @controller.stubs(:profile).returns(Enterprise.create(:name => 'test_ent', :identifier => 'test_ent')) assert_includes @controller.available_article_types, EnterpriseHomepage end @@ -767,7 +767,7 @@ class CmsControllerTest < Test::Unit::TestCase end should 'not offer folder to blog articles' do - @controller.stubs(:profile).returns(Enterprise.new) + @controller.stubs(:profile).returns(Enterprise.create(:name => 'test_ent', :identifier => 'test_ent')) blog = Blog.create!(:name => 'Blog for test', :profile => profile) @controller.stubs(:params).returns({ :parent_id => blog.id }) @@ -775,7 +775,7 @@ class CmsControllerTest < Test::Unit::TestCase end should 'not offer rssfeed to blog articles' do - @controller.stubs(:profile).returns(Enterprise.new) + @controller.stubs(:profile).returns(Enterprise.create(:name => 'test_ent', :identifier => 'test_ent')) blog = Blog.create!(:name => 'Blog for test', :profile => profile) @controller.stubs(:params).returns({ :parent_id => blog.id }) @@ -1137,4 +1137,15 @@ class CmsControllerTest < Test::Unit::TestCase assert_no_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/upload_files?parent_id=#{profile.blog.id}"} end + should 'not offer to create events if events is disabled' do + e = profile.environment + e.enable(:disable_asset_events) + e.save! + + get :new, :profile => profile.identifier + + + assert_not_includes assigns(:article_types).map{|at|at[:name]}, 'Event' + end + end -- libgit2 0.21.2