From 6be1446fc7f4b159097533562920662b85155113 Mon Sep 17 00:00:00 2001 From: Yi Feng Date: Sat, 20 Apr 2019 18:05:58 +0800 Subject: normalize the hash of transformations --- activestorage/app/models/active_storage/variation.rb | 2 +- activestorage/test/models/variant_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'activestorage') 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/test/models/variant_test.rb b/activestorage/test/models/variant_test.rb index d98935eb9f..f6fa0e7afa 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 -- cgit v1.2.3