aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/files/racecar.jpgbin0 -> 1124062 bytes
-rw-r--r--test/test_helper.rb3
-rw-r--r--test/variation_test.rb16
3 files changed, 19 insertions, 0 deletions
diff --git a/test/fixtures/files/racecar.jpg b/test/fixtures/files/racecar.jpg
new file mode 100644
index 0000000000..934b4caa22
--- /dev/null
+++ b/test/fixtures/files/racecar.jpg
Binary files differ
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 03593b12c7..878ce8391c 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -24,6 +24,9 @@ ActiveStorage::Service.logger = ActiveSupport::Logger.new(STDOUT)
require "active_storage/verified_key_with_expiration"
ActiveStorage::VerifiedKeyWithExpiration.verifier = ActiveSupport::MessageVerifier.new("Testing")
+require "active_storage/variant"
+ActiveStorage::Variant.verifier = ActiveSupport::MessageVerifier.new("Testing")
+
class ActiveSupport::TestCase
private
def create_blob(data: "Hello world!", filename: "hello.txt", content_type: "text/plain")
diff --git a/test/variation_test.rb b/test/variation_test.rb
new file mode 100644
index 0000000000..3b05095292
--- /dev/null
+++ b/test/variation_test.rb
@@ -0,0 +1,16 @@
+require "test_helper"
+require "database/setup"
+require "active_storage/variant"
+
+class ActiveStorage::VariationTest < ActiveSupport::TestCase
+ test "square variation" do
+ blob = ActiveStorage::Blob.create_after_upload! \
+ io: File.open(File.expand_path("../fixtures/files/racecar.jpg", __FILE__)), filename: "racecar.jpg", content_type: "image/jpeg"
+
+ variation_key = ActiveStorage::Variant.encode_key(resize: "500x500")
+
+ variant = ActiveStorage::Variant.lookup(blob_key: blob.key, variation_key: variation_key)
+
+ assert_match /racecar.jpg/, variant.url
+ end
+end