Created
May 20, 2016 19:07
-
-
Save abepetrillo/0c2df11df6cf7e1023c637f7204115fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class DocumentsControllerTest < ActionController::TestCase | |
test "Uploading a file" do | |
file_path = File.join(Rails.root, 'tmp', SecureRandom.uuid) | |
File.open(file_path, 'w+b') { |f| f.write "A random file used for testing attachments!" } | |
file = Rack::Test::UploadedFile.new(file_path, 'text/plain') | |
post :create, {file: file} | |
assert_response :success | |
assert_equal(Document.last.file, 'A random file used for testing attachments!') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment