diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb index 8d33a49..002de9d 100644 --- a/app/controllers/public/content_viewer_controller.rb +++ b/app/controllers/public/content_viewer_controller.rb @@ -28,8 +28,8 @@ class ContentViewerController < ApplicationController end end - # do not show unpublished articles - if @page && !@page.published + # only show unpublished articles to those who can edit then + if @page && !@page.published && (!user || !user.has_permission?('post_content', profile)) @page = nil end diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index 9620735..cec8473 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -311,6 +311,24 @@ class ContentViewerControllerTest < Test::Unit::TestCase assert_response 404 end + should 'show unpublished articles to the user himself' do + profile.articles.create!(:name => 'test', :published => false) + + login_as(profile.identifier) + get :view_page, :profile => profile.identifier, :page => [ 'test' ] + assert_response :success + end + + should 'show unpublished articles to members' do + community = Community.create!(:name => 'testcomm') + community.articles.create!(:name => 'test', :published => false) + community.add_member(profile) + + login_as(profile.identifier) + get :view_page, :profile => community.identifier, :page => [ 'test' ] + assert_response :success + end + should 'show message for disabled enterprises' do login_as(@profile.identifier) ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false) -- libgit2 0.21.2