Commit 3f3fdf2f8735ac097f3b6460f4e6df67be688dfc
1 parent
45f72756
Exists in
master
and in
23 other branches
ActionItem389: not showing unpublished articles
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1870 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
4 changed files
with
31 additions
and
1 deletions
Show diff stats
app/controllers/public/content_viewer_controller.rb
| ... | ... | @@ -17,8 +17,11 @@ class ContentViewerController < PublicController |
| 17 | 17 | @page = profile.articles.find_by_path(path) |
| 18 | 18 | |
| 19 | 19 | # do not show unpublished articles |
| 20 | - @page = nil unless @page.published | |
| 20 | + if @page && !@page.published | |
| 21 | + @page = nil | |
| 22 | + end | |
| 21 | 23 | |
| 24 | + # page not found, give error | |
| 22 | 25 | if @page.nil? |
| 23 | 26 | render_not_found(@path) |
| 24 | 27 | return | ... | ... |
app/views/cms/edit.rhtml
| ... | ... | @@ -21,6 +21,14 @@ |
| 21 | 21 | <%= f.text_field('tag_list', :size => 64) %> |
| 22 | 22 | <%= content_tag( 'small', _('Separate tags with commas') ) %> |
| 23 | 23 | |
| 24 | + <div id='edit-article-options'> | |
| 25 | + <h4><%= _('Options') %></h4> | |
| 26 | + <div> | |
| 27 | + <%= check_box :article, :published %> | |
| 28 | + <label for='article_published'><%= _('Published')%></label> | |
| 29 | + </div> | |
| 30 | + </div> | |
| 31 | + | |
| 24 | 32 | <% button_bar do %> |
| 25 | 33 | <%= submit_button :save, _('Save') %> |
| 26 | 34 | <% if @parent_id || @article.parent %> | ... | ... |
test/functional/cms_controller_test.rb
| ... | ... | @@ -416,4 +416,17 @@ class CmsControllerTest < Test::Unit::TestCase |
| 416 | 416 | assert_tag :tag => 'a', :attributes => { :rel => 'deactivate'} # lightbox close button |
| 417 | 417 | end |
| 418 | 418 | |
| 419 | + should 'display published option' do | |
| 420 | + get :edit, :profile => profile.identifier, :id => profile.home_page.id | |
| 421 | + assert_tag :tag => 'input', :attributes => { :type => 'checkbox', :name => 'article[published]', :checked => 'checked' } | |
| 422 | + end | |
| 423 | + | |
| 424 | + should "display properly a non-published articles' status" do | |
| 425 | + article = profile.articles.create!(:name => 'test', :published => false) | |
| 426 | + | |
| 427 | + get :edit, :profile => profile.identifier, :id => article.id | |
| 428 | + assert_tag :tag => 'input', :attributes => { :type => 'checkbox', :name => 'article[published]' } | |
| 429 | + assert_no_tag :tag => 'input', :attributes => { :type => 'checkbox', :name => 'article[published]', :checked => 'checked' } | |
| 430 | + end | |
| 431 | + | |
| 419 | 432 | end | ... | ... |
test/functional/content_viewer_controller_test.rb
| ... | ... | @@ -247,6 +247,12 @@ class ContentViewerControllerTest < Test::Unit::TestCase |
| 247 | 247 | assert_response 200 |
| 248 | 248 | end |
| 249 | 249 | |
| 250 | + should 'give 404 status on unexisting article' do | |
| 251 | + profile.articles.delete_all | |
| 252 | + get :view_page, :profile => profile.identifier, :page => [ 'VERY-UNPROBABLE-PAGE' ] | |
| 253 | + assert_response 404 | |
| 254 | + end | |
| 255 | + | |
| 250 | 256 | should 'show unpublished articles as unexisting' do |
| 251 | 257 | profile.articles.create!(:name => 'test', :published => false) |
| 252 | 258 | get :view_page, :profile => profile.identifier, :page => [ 'test' ] | ... | ... |