Я пишу тесты для созданного мной контроллера ресурсов.Я хочу проверить, что действие перенаправляет на правильный URL-адрес файла, однако я получаю ошибку URI::InvalidURIError: bad URI(is not URI?): nil
из моей существующей настройки устройства, поэтому я предполагаю, что мне нужно где-то хранить капли.Любая помощь будет отличной!
class StorageController < ActionController::Base
include ActionController::Live
def resource
filename = "#{params.fetch(:filename)}.#{params.fetch(:format)}"
resource = Resource.find_by!(name: filename)
redirect_to resource.file.service_url
end
end
require 'test_helper'
class StorageControllerTest < ActionDispatch::IntegrationTest
test "resources redirects to resource" do
get resource_storage_path(resources(:summary).name)
assert_redirected_to resources(:summary).file.service_url
end
end
#blobs.yml
summary_blob:
key: aabbWNGW1VrxZ8Eu4zma23ja
filename: 'summary.pdf'
content_type: 'application/pdf'
metadata: '{"identified":true,"analyzed":true}'
byte_size: <%= File.size('tmp/storage/aa/bb/aabbWNGW1VrxZ8Eu4zma23ja') %>
checksum: <%= Digest::MD5.file('tmp/storage/aa/bb/aabbWNGW1VrxZ8Eu4zma23ja').base64digest %>
created_at: <%= DateTime.now %>
#attachments.yml
summary_attachment:
name: file
record: summary (Resource)
blob: summary_blob
created_at: <%= DateTime.now %>
#resources.yml
summary:
name: 2019_event_summary.pdf