fixture_file_upload

Reading time ~1 minute

Rails 测试的时候使用 fixture_file_upload 上传文件

  test "all_active_storage_attachments" do
    assert_empty @order.all_active_storage_attachments
    file = fixture_file_upload(Rails.root.join('public', 'apple-touch-icon.png'), 'image/png')
    @order_credit.idcode_front.attach file
    assert_not_empty @order.all_active_storage_attachments
  end
comments powered by Disqus