diff --git a/app/models/image.rb b/app/models/image.rb index 4d479d282..1f541171b 100644 --- a/app/models/image.rb +++ b/app/models/image.rb @@ -41,9 +41,9 @@ class Image < ApplicationRecord def variant(style) if style - attachment.variant(self.class.styles[style]) + attachment.variant(self.class.styles[style].merge(strip: true)) else - attachment + attachment.variant(strip: true) end end diff --git a/spec/fixtures/files/logo_header_with_metadata.jpg b/spec/fixtures/files/logo_header_with_metadata.jpg new file mode 100644 index 000000000..ccc1d4ef8 Binary files /dev/null and b/spec/fixtures/files/logo_header_with_metadata.jpg differ diff --git a/spec/system/images_spec.rb b/spec/system/images_spec.rb new file mode 100644 index 000000000..b9732b5c9 --- /dev/null +++ b/spec/system/images_spec.rb @@ -0,0 +1,25 @@ +require "rails_helper" + +describe "Images" do + before { Setting["uploads.images.min_height"] = 0 } + + describe "Metadata" do + let(:image) { create(:image, attachment: fixture_file_upload("logo_header_with_metadata.jpg")) } + + scenario "download original images without metadata" do + visit polymorphic_path(image.variant(nil)) + + file = MiniMagick::Image.open(page.find("img")["src"]) + + expect(file.exif).to be_empty + end + + scenario "download transformed images without metadata" do + visit polymorphic_path(image.variant(:large)) + + file = MiniMagick::Image.open(page.find("img")["src"]) + + expect(file.exif).to be_empty + end + end +end