aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage
diff options
context:
space:
mode:
Diffstat (limited to 'activestorage')
-rw-r--r--activestorage/CHANGELOG.md4
-rw-r--r--activestorage/app/models/active_storage/variation.rb2
-rw-r--r--activestorage/lib/active_storage/engine.rb2
-rw-r--r--activestorage/test/fixtures/files/colors.bmpbin0 -> 2810 bytes
-rw-r--r--activestorage/test/models/variant_test.rb19
5 files changed, 26 insertions, 1 deletions
diff --git a/activestorage/CHANGELOG.md b/activestorage/CHANGELOG.md
index 54fc949172..d524ecf7d6 100644
--- a/activestorage/CHANGELOG.md
+++ b/activestorage/CHANGELOG.md
@@ -1,3 +1,7 @@
+* Permit generating variants of BMP images.
+
+ *Younes Serraj*
+
## Rails 6.0.0.beta3 (March 11, 2019) ##
* No changes.
diff --git a/activestorage/app/models/active_storage/variation.rb b/activestorage/app/models/active_storage/variation.rb
index 41b5a45f53..45ae71e0ca 100644
--- a/activestorage/app/models/active_storage/variation.rb
+++ b/activestorage/app/models/active_storage/variation.rb
@@ -40,7 +40,7 @@ class ActiveStorage::Variation
end
def initialize(transformations)
- @transformations = transformations
+ @transformations = transformations.deep_symbolize_keys
end
# Accepts a File object, performs the +transformations+ against it, and
diff --git a/activestorage/lib/active_storage/engine.rb b/activestorage/lib/active_storage/engine.rb
index fc75a8f816..cbb205627e 100644
--- a/activestorage/lib/active_storage/engine.rb
+++ b/activestorage/lib/active_storage/engine.rb
@@ -33,6 +33,7 @@ module ActiveStorage
image/jpeg
image/pjpeg
image/tiff
+ image/bmp
image/vnd.adobe.photoshop
image/vnd.microsoft.icon
)
@@ -56,6 +57,7 @@ module ActiveStorage
image/jpg
image/jpeg
image/tiff
+ image/bmp
image/vnd.adobe.photoshop
image/vnd.microsoft.icon
application/pdf
diff --git a/activestorage/test/fixtures/files/colors.bmp b/activestorage/test/fixtures/files/colors.bmp
new file mode 100644
index 0000000000..3cc1e8764d
--- /dev/null
+++ b/activestorage/test/fixtures/files/colors.bmp
Binary files differ
diff --git a/activestorage/test/models/variant_test.rb b/activestorage/test/models/variant_test.rb
index d98935eb9f..6b43923159 100644
--- a/activestorage/test/models/variant_test.rb
+++ b/activestorage/test/models/variant_test.rb
@@ -4,6 +4,14 @@ require "test_helper"
require "database/setup"
class ActiveStorage::VariantTest < ActiveSupport::TestCase
+ test "variations have the same key for different types of the same transformation" do
+ blob = create_file_blob(filename: "racecar.jpg")
+ variant_a = blob.variant(resize: "100x100")
+ variant_b = blob.variant("resize" => "100x100")
+
+ assert_equal variant_a.key, variant_b.key
+ end
+
test "resized variation of JPEG blob" do
blob = create_file_blob(filename: "racecar.jpg")
variant = blob.variant(resize: "100x100").processed
@@ -144,6 +152,17 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase
assert_equal 33, image.height
end
+ test "resized variation of BMP blob" do
+ blob = create_file_blob(filename: "colors.bmp")
+ variant = blob.variant(resize: "15x15").processed
+ assert_match(/colors\.bmp/, variant.service_url)
+
+ image = read_image(variant)
+ assert_equal "BMP", image.type
+ assert_equal 15, image.width
+ assert_equal 8, image.height
+ end
+
test "optimized variation of GIF blob" do
blob = create_file_blob(filename: "image.gif", content_type: "image/gif")