-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
This rather contrived test is what can happen if you try to save a model twice (e.g. to create a record to get it's id then update some attributes based on that id). Maybe this is a stupid thing to do but if you do it, Rails seems to close the temp file behind our back and the before_validation done by file_upload_cache generates an IOError when it tries to rewind the closed file.
Are you interested in a patch to fix this test or do you think there's a better way to solve this problem?
def test_validation_stores_item_in_cache2
omg = MockOmg.new
file = ActionDispatch::Http::UploadedFile.new(:tempfile => File.open(File.expand_path('test/fixtures/sadface.jpg')))
omg.omg_file = file
cached_file = omg.cached_omg_file
assert_equal nil, cached_file
omg.valid?
cached_file = omg.cached_omg_file
assert cached_file.is_a?(FileUploadCache::CachedFile)
assert ! cached_file.id.blank?
fetched_cached_file = FileUploadCache::CachedFile.find(cached_file.id)
assert_equal cached_file, fetched_cached_file
file.tempfile.close
assert omg.valid?
endReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels