discourse/spec/requests/api/uploads_spec.rb
Blake Erickson 798b479e0d
DEV: More API Doc improvements (#11849)
- Create helper wrapper method `load_spec_schema(name)`
- A minor change to tag_group_create response schema
- Document the uploads endpoint
2021-01-26 07:38:46 -07:00

43 lines
1.1 KiB
Ruby

# frozen_string_literal: true
require 'swagger_helper'
describe 'uploads' do
let(:admin) { Fabricate(:admin) }
let(:logo_file) { file_from_fixtures("logo.png") }
let(:logo) { Rack::Test::UploadedFile.new(logo_file) }
before do
Jobs.run_immediately!
sign_in(admin)
end
path '/uploads.json' do
post 'Creates an upload' do
tags 'Uploads'
consumes 'multipart/form-data'
expected_request_schema = load_spec_schema('upload_create_request')
parameter name: :params, in: :body, schema: expected_request_schema
let(:params) { {
type: 'avatar',
user_id: admin.id,
synchronous: true,
file: logo
} }
produces 'application/json'
response '200', 'file uploaded' do
expected_response_schema = load_spec_schema('upload_create_response')
schema(expected_response_schema)
# Skipping this test for now until https://github.com/rswag/rswag/issues/348
# is resolved. This still allows the docs to be generated for this endpoint though.
xit
end
end
end
end