Skip to content

Commit

Permalink
Remove AttachmentsController#show custom caching
Browse files Browse the repository at this point in the history
Attachment masked files are now stored in `ActiveStorage` we don't also
need to store in the old views cache.
  • Loading branch information
gbp committed Aug 3, 2023
1 parent 00851fd commit 9581868
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
2 changes: 1 addition & 1 deletion app/controllers/attachments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AttachmentsController < ApplicationController
before_action :authenticate_attachment
before_action :authenticate_attachment_as_html, only: :show_as_html

around_action :cache_attachments
around_action :cache_attachments, only: :show_as_html

def show
if @attachment.masked?
Expand Down
21 changes: 0 additions & 21 deletions spec/controllers/attachments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,6 @@ def show(params = {})
get :show, params: default_params.merge(params)
end

it 'should cache an attachment on a request with normal prominence' do
expect(@controller).to receive(:foi_fragment_cache_write)
show
end

it 'sets the correct read permissions for the new file' do
# allow file to be written to disk
allow(@controller).to receive(:foi_fragment_cache_write).and_call_original

# write file to disk
show

# check the file permissions
key_path = @controller.send(:cache_key_path)
octal_stat = format('%o', File.stat(key_path).mode)[-4..-1]
expect(octal_stat).to eq('0644')

# clean up and remove the file
File.delete(key_path)
end

# This is a regression test for a bug where URLs of this form were causing
# 500 errors instead of 404s.
#
Expand Down

0 comments on commit 9581868

Please sign in to comment.