2017-08-12 08:32:15 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-07-21 17:12:29 -04:00
|
|
|
require "test_helper"
|
|
|
|
require "database/setup"
|
|
|
|
|
2017-07-27 16:15:38 -04:00
|
|
|
class ActiveStorage::VariantsControllerTest < ActionDispatch::IntegrationTest
|
2017-07-21 17:12:29 -04:00
|
|
|
setup do
|
2017-09-28 16:43:37 -04:00
|
|
|
@blob = create_file_blob filename: "racecar.jpg"
|
2017-07-21 17:12:29 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
test "showing variant inline" do
|
2017-07-27 16:15:38 -04:00
|
|
|
get rails_blob_variation_url(
|
2017-07-21 17:12:29 -04:00
|
|
|
filename: @blob.filename,
|
2017-07-23 12:05:20 -04:00
|
|
|
signed_blob_id: @blob.signed_id,
|
2017-07-27 16:15:38 -04:00
|
|
|
variation_key: ActiveStorage::Variation.encode(resize: "100x100"))
|
2017-07-21 17:12:29 -04:00
|
|
|
|
2017-08-14 09:17:50 -04:00
|
|
|
assert_redirected_to(/racecar\.jpg\?.*disposition=inline/)
|
2017-07-26 14:58:59 -04:00
|
|
|
|
2017-09-28 16:43:37 -04:00
|
|
|
image = read_image(@blob.variant(resize: "100x100"))
|
2017-07-26 14:58:59 -04:00
|
|
|
assert_equal 100, image.width
|
|
|
|
assert_equal 67, image.height
|
2017-07-21 17:12:29 -04:00
|
|
|
end
|
2017-12-15 19:26:53 -05:00
|
|
|
|
|
|
|
test "showing variant with invalid signed blob ID" do
|
|
|
|
get rails_blob_variation_url(
|
|
|
|
filename: @blob.filename,
|
|
|
|
signed_blob_id: "invalid",
|
|
|
|
variation_key: ActiveStorage::Variation.encode(resize: "100x100"))
|
|
|
|
|
|
|
|
assert_response :not_found
|
|
|
|
end
|
2017-07-21 17:12:29 -04:00
|
|
|
end
|