Commit 1a35b393b16b0ea943f2b2c9c8ba58a4839addfa
1 parent
a917f8f8
Exists in
master
and in
22 other branches
ActionItem24: not offering to create a child of a no-child article
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1148 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
29 additions
and
1 deletions
Show diff stats
app/views/cms/view.rhtml
| @@ -36,7 +36,9 @@ | @@ -36,7 +36,9 @@ | ||
| 36 | 36 | ||
| 37 | <% if @article %> | 37 | <% if @article %> |
| 38 | <% button_bar(:class => 'file-manager-controls') do %> | 38 | <% button_bar(:class => 'file-manager-controls') do %> |
| 39 | - <%= button('new', _('New subitem'), :action => 'new', :parent_id => @article.id) %> | 39 | + <% if @article.allow_children? %> |
| 40 | + <%= button('new', _('New subitem'), :action => 'new', :parent_id => @article.id) %> | ||
| 41 | + <% end %> | ||
| 40 | <%= button('up', _('Go up one level'), :action => (@article.parent ? 'view' : 'index'), :id => @article.parent) %> | 42 | <%= button('up', _('Go up one level'), :action => (@article.parent ? 'view' : 'index'), :id => @article.parent) %> |
| 41 | <% end %> | 43 | <% end %> |
| 42 | <% end %> | 44 | <% end %> |
test/functional/cms_controller_test.rb
| @@ -172,7 +172,33 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -172,7 +172,33 @@ class CmsControllerTest < Test::Unit::TestCase | ||
| 172 | flunk 'pending' | 172 | flunk 'pending' |
| 173 | end | 173 | end |
| 174 | 174 | ||
| 175 | + should 'offer to create children' do | ||
| 176 | + Article.any_instance.stubs(:allow_children?).returns(true) | ||
| 177 | + | ||
| 178 | + article = Article.new(:name => 'test') | ||
| 179 | + article.profile = profile | ||
| 180 | + article.save! | ||
| 181 | + | ||
| 182 | + get :view, :profile => profile.identifier, :id => article.id | ||
| 183 | + assert_response :success | ||
| 184 | + assert_template 'view' | ||
| 185 | + assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{article.id}"} | ||
| 186 | + end | ||
| 187 | + | ||
| 175 | should 'not offer to create children if article does not accept them' do | 188 | should 'not offer to create children if article does not accept them' do |
| 189 | + Article.any_instance.stubs(:allow_children?).returns(false) | ||
| 190 | + | ||
| 191 | + article = Article.new(:name => 'test') | ||
| 192 | + article.profile = profile | ||
| 193 | + article.save! | ||
| 194 | + | ||
| 195 | + get :view, :profile => profile.identifier, :id => article.id | ||
| 196 | + assert_response :success | ||
| 197 | + assert_template 'view' | ||
| 198 | + assert_no_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{article.id}"} | ||
| 199 | + end | ||
| 200 | + | ||
| 201 | + should 'not allow to create children of non-child articles' do | ||
| 176 | flunk 'pending' | 202 | flunk 'pending' |
| 177 | end | 203 | end |
| 178 | 204 |