1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Test actual transformation via controller too

This commit is contained in:
David Heinemeier Hansson 2017-07-21 16:45:55 -05:00
parent e9cf92cc39
commit f3b092a6e6
3 changed files with 7 additions and 7 deletions

View file

@ -19,5 +19,6 @@ class ActiveStorage::VariantsControllerTest < ActionController::TestCase
variation_key: ActiveStorage::Variation.encode(resize: "100x100") }
assert_redirected_to /racecar.jpg\?disposition=inline/
assert_same_image "racecar-100x100.jpg", @blob.variant(resize: "100x100")
end
end

View file

@ -39,6 +39,12 @@ class ActiveSupport::TestCase
io: File.open(File.expand_path("../fixtures/files/#{filename}", __FILE__)),
filename: filename, content_type: content_type
end
def assert_same_image(fixture_filename, variant)
assert_equal \
File.binread(File.expand_path("../fixtures/files/#{fixture_filename}", __FILE__)),
File.binread(variant.service.send(:path_for, variant.key))
end
end
require "action_controller"

View file

@ -20,11 +20,4 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase
assert_match /racecar.jpg/, variant.url
assert_same_image "racecar-100x100-monochrome.jpg", variant
end
private
def assert_same_image(fixture_filename, variant)
assert_equal \
File.binread(File.expand_path("../fixtures/files/#{fixture_filename}", __FILE__)),
File.binread(variant.service.send(:path_for, variant.key))
end
end