diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2019-01-22 11:09:04 +0100 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2019-01-22 12:34:11 +0100 |
commit | 2d057da183b35d4b4eca6eda8b005d7d068c342a (patch) | |
tree | 7c0d0f484707027d29f5faeeb32052f1e54b90ba | |
parent | 86cda964cf7f289c8b0cd1efa80b3bd4bacfec4e (diff) | |
download | gitlab-ce-2d057da183b35d4b4eca6eda8b005d7d068c342a.tar.gz |
Turned cache_privately? into cache_publicly?
Also removed unnecessary comment
-rw-r--r-- | app/controllers/concerns/uploads_actions.rb | 10 | ||||
-rw-r--r-- | app/controllers/uploads_controller.rb | 4 | ||||
-rw-r--r-- | spec/controllers/uploads_controller_spec.rb | 1 |
3 files changed, 7 insertions, 8 deletions
diff --git a/app/controllers/concerns/uploads_actions.rb b/app/controllers/concerns/uploads_actions.rb index 7106c61e749..4ec0e94df9a 100644 --- a/app/controllers/concerns/uploads_actions.rb +++ b/app/controllers/concerns/uploads_actions.rb @@ -29,12 +29,12 @@ module UploadsActions def show return render_404 unless uploader&.exists? - if cache_privately? - expires_in 0.seconds, must_revalidate: true, private: true - else + if cache_publicly? # We need to reset caching from the applications controller to get rid of the no-store value headers['Cache-Control'] = '' expires_in 5.minutes, public: true, must_revalidate: false + else + expires_in 0.seconds, must_revalidate: true, private: true end disposition = uploader.image_or_video? ? 'inline' : 'attachment' @@ -120,8 +120,8 @@ module UploadsActions nil end - def cache_privately? - true + def cache_publicly? + false end def model diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 12f1d487f30..519e7439205 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -70,8 +70,8 @@ class UploadsController < ApplicationController end end - def cache_privately? - true unless User === model || Appearance === model + def cache_publicly? + User === model || Appearance === model end def upload_model_class diff --git a/spec/controllers/uploads_controller_spec.rb b/spec/controllers/uploads_controller_spec.rb index f731ac2971b..5fbb71eca96 100644 --- a/spec/controllers/uploads_controller_spec.rb +++ b/spec/controllers/uploads_controller_spec.rb @@ -14,7 +14,6 @@ end shared_examples 'content publicly cached' do it 'ensures content is publicly cached' do - # Fixed in newer versions of ActivePack, it will only output a single `private`. expect(subject['Cache-Control']).to eq('max-age=300, public') end end |