diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-21 16:12:29 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-21 16:12:29 -0500 |
commit | 796f8330ad441e93590a57521ef8fb80a030fb66 (patch) | |
tree | d69396c2ac693de55aebbdc5f1e3df01e69d1fc0 /test | |
parent | 67606dcdf52ae7f83e42a9872fdc545b02f227a2 (diff) | |
download | rails-796f8330ad441e93590a57521ef8fb80a030fb66.tar.gz rails-796f8330ad441e93590a57521ef8fb80a030fb66.tar.bz2 rails-796f8330ad441e93590a57521ef8fb80a030fb66.zip |
Fix and test VariantsController
Diffstat (limited to 'test')
-rw-r--r-- | test/controllers/variants_controller.rb | 25 | ||||
-rw-r--r-- | test/test_helper.rb | 2 |
2 files changed, 27 insertions, 0 deletions
diff --git a/test/controllers/variants_controller.rb b/test/controllers/variants_controller.rb new file mode 100644 index 0000000000..132d93a3cf --- /dev/null +++ b/test/controllers/variants_controller.rb @@ -0,0 +1,25 @@ +require "test_helper" +require "database/setup" + +require "active_storage/variants_controller" +require "active_storage/verified_key_with_expiration" + +class ActiveStorage::VariantsControllerTest < ActionController::TestCase + setup do + @blob = ActiveStorage::Blob.create_after_upload! \ + filename: "racecar.jpg", content_type: "image/jpeg", + io: File.open(File.expand_path("../../fixtures/files/racecar.jpg", __FILE__)) + + @routes = Routes + @controller = ActiveStorage::VariantsController.new + end + + test "showing variant inline" do + get :show, params: { + filename: @blob.filename, + encoded_blob_key: ActiveStorage::VerifiedKeyWithExpiration.encode(@blob.key, expires_in: 5.minutes), + variation_key: ActiveStorage::Variation.encode(resize: "100x100") } + + assert_redirected_to /racecar.jpg\?disposition=inline/ + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index e98b6e0afc..7aa7b50bf3 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,5 @@ +$LOAD_PATH << File.expand_path("../../app/controllers", __FILE__) + require "bundler/setup" require "active_support" require "active_support/test_case" |