Commit 99fa04df9a85351aafa03ad0adcdbf27f6658960
1 parent
3c206e7b
Exists in
master
and in
27 other branches
Don't cache error responses (status >= 400)
Showing
3 changed files
with
26 additions
and
1 deletions
Show diff stats
app/controllers/public/profile_controller.rb
test/integration/http_caching_test.rb
| ... | ... | @@ -74,6 +74,23 @@ class HttpCachingTest < ActionController::IntegrationTest |
| 74 | 74 | assert_no_cache |
| 75 | 75 | end |
| 76 | 76 | |
| 77 | + test 'private community profile should not return cache headers' do | |
| 78 | + create_private_community('the-community') | |
| 79 | + | |
| 80 | + get "/profile/the-community" | |
| 81 | + assert_response 403 | |
| 82 | + assert_no_cache | |
| 83 | + end | |
| 84 | + | |
| 85 | + test 'private community content should not return cache headers' do | |
| 86 | + community = create_private_community('the-community') | |
| 87 | + create(Article, profile_id: community.id, name: 'Test page') | |
| 88 | + | |
| 89 | + get "/the-community/test-page" | |
| 90 | + assert_response 403 | |
| 91 | + assert_no_cache | |
| 92 | + end | |
| 93 | + | |
| 77 | 94 | protected |
| 78 | 95 | |
| 79 | 96 | def set_env_config(data) |
| ... | ... | @@ -84,6 +101,13 @@ class HttpCachingTest < ActionController::IntegrationTest |
| 84 | 101 | env.save! |
| 85 | 102 | end |
| 86 | 103 | |
| 104 | + def create_private_community(identifier) | |
| 105 | + community = fast_create(Community, identifier: identifier) | |
| 106 | + community.public_profile = false | |
| 107 | + community.save! | |
| 108 | + community | |
| 109 | + end | |
| 110 | + | |
| 87 | 111 | def assert_no_cache |
| 88 | 112 | assert(cache_parts == ['max-age=0', 'must-revalidate', 'private'] || cache_parts == ['no-cache'], "should not set cache headers (found #{cache_parts.inspect})") |
| 89 | 113 | end | ... | ... |