未验证 提交 1d984246 编写于 作者: M Matthew Draper 提交者: GitHub

Merge pull request #33723 from pinewong/patch-3

Clarify example of the test [ci skip]
...@@ -8,12 +8,12 @@ module TestProcess ...@@ -8,12 +8,12 @@ module TestProcess
module FixtureFile module FixtureFile
# Shortcut for <tt>Rack::Test::UploadedFile.new(File.join(ActionDispatch::IntegrationTest.fixture_path, path), type)</tt>: # Shortcut for <tt>Rack::Test::UploadedFile.new(File.join(ActionDispatch::IntegrationTest.fixture_path, path), type)</tt>:
# #
# post :change_avatar, avatar: fixture_file_upload('files/spongebob.png', 'image/png') # post :change_avatar, params: { avatar: fixture_file_upload('files/spongebob.png', 'image/png') }
# #
# To upload binary files on Windows, pass <tt>:binary</tt> as the last parameter. # To upload binary files on Windows, pass <tt>:binary</tt> as the last parameter.
# This will not affect other platforms: # This will not affect other platforms:
# #
# post :change_avatar, avatar: fixture_file_upload('files/spongebob.png', 'image/png', :binary) # post :change_avatar, params: { avatar: fixture_file_upload('files/spongebob.png', 'image/png', :binary) }
def fixture_file_upload(path, mime_type = nil, binary = false) def fixture_file_upload(path, mime_type = nil, binary = false)
if self.class.respond_to?(:fixture_path) && self.class.fixture_path && if self.class.respond_to?(:fixture_path) && self.class.fixture_path &&
!File.exist?(path) !File.exist?(path)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册