Extract constant to configure valid mime types

This way it'll be possible to overwrite the valid mime types in a custom
model.
This commit is contained in:
Javi Martín
2022-08-03 15:49:22 +02:00
parent 00ea1bf719
commit 11bed74678
2 changed files with 17 additions and 1 deletions

View File

@@ -44,4 +44,18 @@ describe SiteCustomization::Image do
expect(map).not_to be_valid
end
end
it "dynamically validates the valid mime types" do
stub_const("#{SiteCustomization::Image}::VALID_MIME_TYPES", ["image/gif"])
gif = build(:site_customization_image,
name: "logo_header",
image: fixture_file_upload("logo_header.gif"))
expect(gif).to be_valid
png = build(:site_customization_image,
name: "logo_header",
image: fixture_file_upload("logo_header.png"))
expect(png).not_to be_valid
end
end