diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb
index 87a2113..a1381d2 100644
--- a/app/controllers/public/content_viewer_controller.rb
+++ b/app/controllers/public/content_viewer_controller.rb
@@ -17,8 +17,11 @@ class ContentViewerController < PublicController
@page = profile.articles.find_by_path(path)
# do not show unpublished articles
- @page = nil unless @page.published
+ if @page && !@page.published
+ @page = nil
+ end
+ # page not found, give error
if @page.nil?
render_not_found(@path)
return
diff --git a/app/views/cms/edit.rhtml b/app/views/cms/edit.rhtml
index d7069c2..b7bb419 100644
--- a/app/views/cms/edit.rhtml
+++ b/app/views/cms/edit.rhtml
@@ -21,6 +21,14 @@
<%= f.text_field('tag_list', :size => 64) %>
<%= content_tag( 'small', _('Separate tags with commas') ) %>
+
+
<%= _('Options') %>
+
+ <%= check_box :article, :published %>
+
+
+
+
<% button_bar do %>
<%= submit_button :save, _('Save') %>
<% if @parent_id || @article.parent %>
diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb
index c8d90d4..9eb27ac 100644
--- a/test/functional/cms_controller_test.rb
+++ b/test/functional/cms_controller_test.rb
@@ -416,4 +416,17 @@ class CmsControllerTest < Test::Unit::TestCase
assert_tag :tag => 'a', :attributes => { :rel => 'deactivate'} # lightbox close button
end
+ should 'display published option' do
+ get :edit, :profile => profile.identifier, :id => profile.home_page.id
+ assert_tag :tag => 'input', :attributes => { :type => 'checkbox', :name => 'article[published]', :checked => 'checked' }
+ end
+
+ should "display properly a non-published articles' status" do
+ article = profile.articles.create!(:name => 'test', :published => false)
+
+ get :edit, :profile => profile.identifier, :id => article.id
+ assert_tag :tag => 'input', :attributes => { :type => 'checkbox', :name => 'article[published]' }
+ assert_no_tag :tag => 'input', :attributes => { :type => 'checkbox', :name => 'article[published]', :checked => 'checked' }
+ end
+
end
diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb
index 4a1b675..087da63 100644
--- a/test/functional/content_viewer_controller_test.rb
+++ b/test/functional/content_viewer_controller_test.rb
@@ -247,6 +247,12 @@ class ContentViewerControllerTest < Test::Unit::TestCase
assert_response 200
end
+ should 'give 404 status on unexisting article' do
+ profile.articles.delete_all
+ get :view_page, :profile => profile.identifier, :page => [ 'VERY-UNPROBABLE-PAGE' ]
+ assert_response 404
+ end
+
should 'show unpublished articles as unexisting' do
profile.articles.create!(:name => 'test', :published => false)
get :view_page, :profile => profile.identifier, :page => [ 'test' ]
--
libgit2 0.21.2