Commit a8bffeabdbe3364f6643e3f8374d8a057d9912d6

Authored by Joenio Costa
Committed by Antonio Terceiro
1 parent d9cfd63a

ActionItem868: create new article inside a folder when view child of folder

app/views/content_viewer/view_page.rhtml
... ... @@ -40,7 +40,7 @@
40 40 { :controller => 'cms', :action => 'publish', :id => @page },
41 41 :class => 'button with-text icon-spread' %>
42 42 <% end %>
43   - <%= lightbox_button(:new, _('New publication'), :controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : nil)) %>
  43 + <%= lightbox_button(:new, _('New publication'), :controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent))) %>
44 44 </div>
45 45 <% end %>
46 46 </div>
... ...
test/functional/content_viewer_controller_test.rb
... ... @@ -556,4 +556,12 @@ class ContentViewerControllerTest &lt; Test::Unit::TestCase
556 556 assert_equal({ :year => year.to_s, :month => month.to_s }, assigns(:page).filter)
557 557 end
558 558  
  559 + should 'give link to create new article inside folder when view child of folder' do
  560 + login_as('testinguser')
  561 + folder = Folder.create!(:name => 'myfolder', :profile => @profile)
  562 + folder.children << TextileArticle.new(:name => 'children-article', :profile => @profile)
  563 + get :view_page, :profile => 'testinguser', :page => [ 'myfolder', 'children-article' ]
  564 + assert_tag :tag => 'div', :attributes => { :class => /main-block/ }, :descendant => { :tag => 'a', :attributes => { :href => "/myprofile/testinguser/cms/new?parent_id=#{folder.id}" } }
  565 + end
  566 +
559 567 end
... ...