FIX: Add onceoff job to remove double quotes from s3 etags
This commit is contained in:
parent
7b5931013a
commit
484bd82278
|
@ -0,0 +1,11 @@
|
||||||
|
module Jobs
|
||||||
|
class FixS3Etags < Jobs::Onceoff
|
||||||
|
|
||||||
|
def execute_onceoff(args)
|
||||||
|
[Upload, OptimizedImage].each do |model|
|
||||||
|
sql = "UPDATE #{model.table_name} SET etag = REGEXP_REPLACE(etag, '\"', '', 'g') WHERE etag LIKE '\"%\"'"
|
||||||
|
DB.exec(sql)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,22 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Jobs::FixS3Etags do
|
||||||
|
let(:etag_with_quotes) { '"ETag"' }
|
||||||
|
let(:etag_without_quotes) { 'ETag' }
|
||||||
|
|
||||||
|
it 'should remove double quotes from etags' do
|
||||||
|
upload1 = Fabricate(:upload, etag: etag_with_quotes)
|
||||||
|
upload2 = Fabricate(:upload, etag: etag_without_quotes)
|
||||||
|
optimized = Fabricate(:optimized_image, etag: etag_with_quotes)
|
||||||
|
|
||||||
|
described_class.new.execute_onceoff({})
|
||||||
|
|
||||||
|
upload1.reload
|
||||||
|
upload2.reload
|
||||||
|
optimized.reload
|
||||||
|
|
||||||
|
expect(upload1.etag).to eq(etag_without_quotes)
|
||||||
|
expect(upload2.etag).to eq(etag_without_quotes)
|
||||||
|
expect(optimized.etag).to eq(etag_without_quotes)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue