diff --git a/app/views/content_viewer/view_page.rhtml b/app/views/content_viewer/view_page.rhtml index b556ad5..9ba5e9c 100644 --- a/app/views/content_viewer/view_page.rhtml +++ b/app/views/content_viewer/view_page.rhtml @@ -40,7 +40,7 @@ { :controller => 'cms', :action => 'publish', :id => @page }, :class => 'button with-text icon-spread' %> <% end %> - <%= lightbox_button(:new, _('New publication'), :controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : nil)) %> + <%= lightbox_button(:new, _('New publication'), :controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent))) %> <% end %> diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index f8f5b4a..238ad2b 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -556,4 +556,12 @@ class ContentViewerControllerTest < Test::Unit::TestCase assert_equal({ :year => year.to_s, :month => month.to_s }, assigns(:page).filter) end + should 'give link to create new article inside folder when view child of folder' do + login_as('testinguser') + folder = Folder.create!(:name => 'myfolder', :profile => @profile) + folder.children << TextileArticle.new(:name => 'children-article', :profile => @profile) + get :view_page, :profile => 'testinguser', :page => [ 'myfolder', 'children-article' ] + assert_tag :tag => 'div', :attributes => { :class => /main-block/ }, :descendant => { :tag => 'a', :attributes => { :href => "/myprofile/testinguser/cms/new?parent_id=#{folder.id}" } } + end + end -- libgit2 0.21.2