summaryrefslogtreecommitdiff
path: root/test/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'test/controllers')
-rw-r--r--test/controllers/assets_controller_test.rb16
1 files changed, 6 insertions, 10 deletions
diff --git a/test/controllers/assets_controller_test.rb b/test/controllers/assets_controller_test.rb
index 59ebab5..f834541 100644
--- a/test/controllers/assets_controller_test.rb
+++ b/test/controllers/assets_controller_test.rb
@@ -70,7 +70,7 @@ class AssetsControllerTest < ActionController::TestCase
70 70
71 # --- create with PDF --- 71 # --- create with PDF ---
72 72
73 test "create asset with PDF upload generates only original" do 73 test "create asset with PDF upload generates rasterized variants" do
74 uploaded = Rack::Test::UploadedFile.new( 74 uploaded = Rack::Test::UploadedFile.new(
75 Rails.root.join('test', 'fixtures', 'files', 'test_document.pdf'), 75 Rails.root.join('test', 'fixtures', 'files', 'test_document.pdf'),
76 'application/pdf' 76 'application/pdf'
@@ -81,18 +81,14 @@ class AssetsControllerTest < ActionController::TestCase
81 assert_response :redirect 81 assert_response :redirect
82 82
83 asset = Asset.last 83 asset = Asset.last
84 assert_equal 'test_document.pdf', asset.upload_file_name 84 original_path = asset.send(:file_path, :original)
85 assert_equal 'application/pdf', asset.upload_content_type
86
87 # only original should exist, no image variants
88 original_path = Rails.root.join('public', 'system', 'uploads',
89 asset.id.to_s, 'original', 'test_document.pdf')
90 assert File.exist?(original_path), "Expected original at #{original_path}" 85 assert File.exist?(original_path), "Expected original at #{original_path}"
86 assert_equal 'test_document.pdf', File.basename(original_path)
91 87
92 %w[medium thumb headline large].each do |style| 88 %w[medium thumb headline large].each do |style|
93 path = Rails.root.join('public', 'system', 'uploads', 89 path = asset.send(:file_path, style)
94 asset.id.to_s, style, 'test_document.pdf') 90 assert File.exist?(path), "Expected a #{style} variant at #{path}"
95 assert !File.exist?(path), "Expected no #{style} variant for PDF" 91 assert_equal '.png', File.extname(path), "Expected #{style} variant to be a PNG, not a PDF"
96 end 92 end
97 end 93 end
98 94