Commit 6d36bda8dfa8c30f96934098c880b73e87c6798c
Committed by
Antonio Terceiro
1 parent
03c411eb
Exists in
master
and in
29 other branches
ActionItem1209: users cannot create events when its disabled
Showing
2 changed files
with
17 additions
and
6 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
| ... | ... | @@ -21,9 +21,9 @@ class CmsController < MyProfileController |
| 21 | 21 | def available_article_types |
| 22 | 22 | articles = [ |
| 23 | 23 | TinyMceArticle, |
| 24 | - TextileArticle, | |
| 25 | - Event | |
| 24 | + TextileArticle | |
| 26 | 25 | ] |
| 26 | + articles << Event unless profile.environment.enabled?(:disable_asset_events) | |
| 27 | 27 | parent_id = params ? params[:parent_id] : nil |
| 28 | 28 | if !parent_id or !Article.find(parent_id).blog? |
| 29 | 29 | articles += [ | ... | ... |
test/functional/cms_controller_test.rb
| ... | ... | @@ -560,12 +560,12 @@ class CmsControllerTest < Test::Unit::TestCase |
| 560 | 560 | end |
| 561 | 561 | |
| 562 | 562 | should 'not make enterprise homepage available to person' do |
| 563 | - @controller.stubs(:profile).returns(Person.new) | |
| 563 | + @controller.stubs(:profile).returns(create_user('test_user').person) | |
| 564 | 564 | assert_not_includes @controller.available_article_types, EnterpriseHomepage |
| 565 | 565 | end |
| 566 | 566 | |
| 567 | 567 | should 'make enterprise homepage available to enterprises' do |
| 568 | - @controller.stubs(:profile).returns(Enterprise.new) | |
| 568 | + @controller.stubs(:profile).returns(Enterprise.create(:name => 'test_ent', :identifier => 'test_ent')) | |
| 569 | 569 | assert_includes @controller.available_article_types, EnterpriseHomepage |
| 570 | 570 | end |
| 571 | 571 | |
| ... | ... | @@ -767,7 +767,7 @@ class CmsControllerTest < Test::Unit::TestCase |
| 767 | 767 | end |
| 768 | 768 | |
| 769 | 769 | should 'not offer folder to blog articles' do |
| 770 | - @controller.stubs(:profile).returns(Enterprise.new) | |
| 770 | + @controller.stubs(:profile).returns(Enterprise.create(:name => 'test_ent', :identifier => 'test_ent')) | |
| 771 | 771 | blog = Blog.create!(:name => 'Blog for test', :profile => profile) |
| 772 | 772 | @controller.stubs(:params).returns({ :parent_id => blog.id }) |
| 773 | 773 | |
| ... | ... | @@ -775,7 +775,7 @@ class CmsControllerTest < Test::Unit::TestCase |
| 775 | 775 | end |
| 776 | 776 | |
| 777 | 777 | should 'not offer rssfeed to blog articles' do |
| 778 | - @controller.stubs(:profile).returns(Enterprise.new) | |
| 778 | + @controller.stubs(:profile).returns(Enterprise.create(:name => 'test_ent', :identifier => 'test_ent')) | |
| 779 | 779 | blog = Blog.create!(:name => 'Blog for test', :profile => profile) |
| 780 | 780 | @controller.stubs(:params).returns({ :parent_id => blog.id }) |
| 781 | 781 | |
| ... | ... | @@ -1137,4 +1137,15 @@ class CmsControllerTest < Test::Unit::TestCase |
| 1137 | 1137 | assert_no_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/upload_files?parent_id=#{profile.blog.id}"} |
| 1138 | 1138 | end |
| 1139 | 1139 | |
| 1140 | + should 'not offer to create events if events is disabled' do | |
| 1141 | + e = profile.environment | |
| 1142 | + e.enable(:disable_asset_events) | |
| 1143 | + e.save! | |
| 1144 | + | |
| 1145 | + get :new, :profile => profile.identifier | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + assert_not_includes assigns(:article_types).map{|at|at[:name]}, 'Event' | |
| 1149 | + end | |
| 1150 | + | |
| 1140 | 1151 | end | ... | ... |