diff --git a/app/controllers/public/profile_controller.rb b/app/controllers/public/profile_controller.rb index 69e087d..18791e7 100644 --- a/app/controllers/public/profile_controller.rb +++ b/app/controllers/public/profile_controller.rb @@ -18,6 +18,7 @@ class ProfileController < PublicController @tags = profile.article_tags unless profile.display_info_to?(user) profile.visible? ? private_profile : invisible_profile + render :action => 'index', :status => 403 end end diff --git a/test/integration/http_caching_test.rb b/test/integration/http_caching_test.rb index 5116c3c..c4cc94a 100644 --- a/test/integration/http_caching_test.rb +++ b/test/integration/http_caching_test.rb @@ -74,6 +74,23 @@ class HttpCachingTest < ActionController::IntegrationTest assert_no_cache end + test 'private community profile should not return cache headers' do + create_private_community('the-community') + + get "/profile/the-community" + assert_response 403 + assert_no_cache + end + + test 'private community content should not return cache headers' do + community = create_private_community('the-community') + create(Article, profile_id: community.id, name: 'Test page') + + get "/the-community/test-page" + assert_response 403 + assert_no_cache + end + protected def set_env_config(data) @@ -84,6 +101,13 @@ class HttpCachingTest < ActionController::IntegrationTest env.save! end + def create_private_community(identifier) + community = fast_create(Community, identifier: identifier) + community.public_profile = false + community.save! + community + end + def assert_no_cache assert(cache_parts == ['max-age=0', 'must-revalidate', 'private'] || cache_parts == ['no-cache'], "should not set cache headers (found #{cache_parts.inspect})") end diff --git a/vendor/plugins/noosfero_caching/init.rb b/vendor/plugins/noosfero_caching/init.rb index 3c08ce2..c786051 100644 --- a/vendor/plugins/noosfero_caching/init.rb +++ b/vendor/plugins/noosfero_caching/init.rb @@ -21,7 +21,7 @@ module NoosferoHttpCaching end end end - if n + if n && response.status < 400 expires_in n.minutes, :private => false, :public => true end end -- libgit2 0.21.2