diff --git a/app/views/cms/view.rhtml b/app/views/cms/view.rhtml
index 91b16e2..eb7f6a4 100644
--- a/app/views/cms/view.rhtml
+++ b/app/views/cms/view.rhtml
@@ -36,7 +36,9 @@
<% if @article %>
<% button_bar(:class => 'file-manager-controls') do %>
- <%= button('new', _('New subitem'), :action => 'new', :parent_id => @article.id) %>
+ <% if @article.allow_children? %>
+ <%= button('new', _('New subitem'), :action => 'new', :parent_id => @article.id) %>
+ <% end %>
<%= button('up', _('Go up one level'), :action => (@article.parent ? 'view' : 'index'), :id => @article.parent) %>
<% end %>
<% end %>
diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb
index 90f33ff..715a0fb 100644
--- a/test/functional/cms_controller_test.rb
+++ b/test/functional/cms_controller_test.rb
@@ -172,7 +172,33 @@ class CmsControllerTest < Test::Unit::TestCase
flunk 'pending'
end
+ should 'offer to create children' do
+ Article.any_instance.stubs(:allow_children?).returns(true)
+
+ article = Article.new(:name => 'test')
+ article.profile = profile
+ article.save!
+
+ get :view, :profile => profile.identifier, :id => article.id
+ assert_response :success
+ assert_template 'view'
+ assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{article.id}"}
+ end
+
should 'not offer to create children if article does not accept them' do
+ Article.any_instance.stubs(:allow_children?).returns(false)
+
+ article = Article.new(:name => 'test')
+ article.profile = profile
+ article.save!
+
+ get :view, :profile => profile.identifier, :id => article.id
+ assert_response :success
+ assert_template 'view'
+ assert_no_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{article.id}"}
+ end
+
+ should 'not allow to create children of non-child articles' do
flunk 'pending'
end
--
libgit2 0.21.2