diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-08-11 17:46:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-11 17:46:02 -0400 |
commit | 4766b2da0299d520c98b24af7a515ee185a32d22 (patch) | |
tree | dcdce39e8d214fc69725529ab72449bc65a2e842 /activestorage/test | |
parent | 701ab978e5967d832a1688f0c7308e7987596cbc (diff) | |
parent | 4287f089d351804a4b2cc0a6df685b010721157c (diff) | |
download | rails-4766b2da0299d520c98b24af7a515ee185a32d22.tar.gz rails-4766b2da0299d520c98b24af7a515ee185a32d22.tar.bz2 rails-4766b2da0299d520c98b24af7a515ee185a32d22.zip |
Merge pull request #30198 from betesh/activestorage-rack-test-uploaded-file
Activestorage rack test uploaded file
Diffstat (limited to 'activestorage/test')
-rw-r--r-- | activestorage/test/models/attachments_test.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/activestorage/test/models/attachments_test.rb b/activestorage/test/models/attachments_test.rb index 58af5dce6e..34cd62dcde 100644 --- a/activestorage/test/models/attachments_test.rb +++ b/activestorage/test/models/attachments_test.rb @@ -18,11 +18,17 @@ class ActiveStorage::AttachmentsTest < ActiveSupport::TestCase assert_equal "funky.jpg", @user.avatar.filename.to_s end - test "attach new blob" do + test "attach new blob from a Hash" do @user.avatar.attach io: StringIO.new("STUFF"), filename: "town.jpg", content_type: "image/jpg" assert_equal "town.jpg", @user.avatar.filename.to_s end + test "attach new blob from an UploadedFile" do + file = file_fixture "racecar.jpg" + @user.avatar.attach Rack::Test::UploadedFile.new file + assert_equal "racecar.jpg", @user.avatar.filename.to_s + end + test "access underlying associations of new blob" do @user.avatar.attach create_blob(filename: "funky.jpg") assert_equal @user, @user.avatar_attachment.record |