Reviewed-on: #355 Co-authored-by: miteruzo <miteruzo@naver.com> Co-committed-by: miteruzo <miteruzo@naver.com>
このコミットはPull リクエスト #355 でマージされました.
このコミットが含まれているのは:
@@ -141,16 +141,21 @@ RSpec.describe 'Materials API', type: :request do
|
||||
context 'when logged in' do
|
||||
before { sign_in_as(guest_user) }
|
||||
|
||||
it 'returns 400 when tag is blank' do
|
||||
it 'returns 422 when tag is blank' do
|
||||
post '/materials', params: { tag: ' ', file: dummy_upload }
|
||||
|
||||
expect(response).to have_http_status(:bad_request)
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(json.fetch('errors')).to include(
|
||||
'tag' => ['タグは必須です.'])
|
||||
end
|
||||
|
||||
it 'returns 400 when both file and url are blank' do
|
||||
it 'returns 422 when both file and url are blank' do
|
||||
post '/materials', params: { tag: 'material_create_blank' }
|
||||
|
||||
expect(response).to have_http_status(:bad_request)
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(json.fetch('errors')).to include(
|
||||
'file' => ['ファイルまたは URL は必須です.'],
|
||||
'url' => ['ファイルまたは URL は必須です.'])
|
||||
end
|
||||
|
||||
it 'creates a material with an attached file' do
|
||||
@@ -261,21 +266,26 @@ RSpec.describe 'Materials API', type: :request do
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
|
||||
it 'returns 400 when tag is blank' do
|
||||
it 'returns 422 when tag is blank' do
|
||||
put "/materials/#{ material.id }", params: {
|
||||
tag: ' ',
|
||||
file: dummy_upload
|
||||
}
|
||||
|
||||
expect(response).to have_http_status(:bad_request)
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(json.fetch('errors')).to include(
|
||||
'tag' => ['タグは必須です.'])
|
||||
end
|
||||
|
||||
it 'returns 400 when both file and url are blank' do
|
||||
it 'returns 422 when both file and url are blank' do
|
||||
put "/materials/#{ material.id }", params: {
|
||||
tag: 'material_update_no_payload'
|
||||
}
|
||||
|
||||
expect(response).to have_http_status(:bad_request)
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(json.fetch('errors')).to include(
|
||||
'file' => ['ファイルまたは URL は必須です.'],
|
||||
'url' => ['ファイルまたは URL は必須です.'])
|
||||
end
|
||||
|
||||
it 'updates tag, url, file, and updated_by_user' do
|
||||
|
||||
新しい課題から参照
ユーザをブロックする