This commit is contained in:
@@ -33,14 +33,14 @@ RSpec.describe 'Posts API', type: :request do
|
||||
|
||||
let!(:hit_post) do
|
||||
Post.create!(uploaded_user: user, title: "hello spec world",
|
||||
url: 'https://example.com/spec').tap do |p|
|
||||
url: 'https://example.com/spec2').tap do |p|
|
||||
PostTag.create!(post: p, tag:)
|
||||
end
|
||||
end
|
||||
|
||||
let!(:miss_post) do
|
||||
Post.create!(uploaded_user: user, title: "unrelated title",
|
||||
url: 'https://example.com/spec2').tap do |p|
|
||||
url: 'https://example.com/spec3').tap do |p|
|
||||
PostTag.create!(post: p, tag: tag2)
|
||||
end
|
||||
end
|
||||
@@ -158,6 +158,36 @@ RSpec.describe 'Posts API', type: :request do
|
||||
expect(json['tags']).to be_an(Array)
|
||||
expect(json['tags'][0]).to have_key('name')
|
||||
end
|
||||
|
||||
context 'when url is blank' do
|
||||
it 'returns 422' do
|
||||
sign_in_as(member)
|
||||
|
||||
post '/posts', params: {
|
||||
title: 'new post',
|
||||
url: ' ',
|
||||
tags: 'spec_tag', # 既存タグ名を投げる
|
||||
thumbnail: dummy_upload
|
||||
}
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when url is invalid' do
|
||||
it 'returns 422' do
|
||||
sign_in_as(member)
|
||||
|
||||
post '/posts', params: {
|
||||
title: 'new post',
|
||||
url: 'ぼざクリタグ広場',
|
||||
tags: 'spec_tag', # 既存タグ名を投げる
|
||||
thumbnail: dummy_upload
|
||||
}
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT /posts/:id' do
|
||||
|
||||
@@ -8,7 +8,9 @@ RSpec.describe 'Wiki API', type: :request do
|
||||
|
||||
let!(:tn) { TagName.create!(name: 'spec_wiki_title') }
|
||||
let!(:page) do
|
||||
WikiPage.create!(tag_name: tn, created_user: user, updated_user: user)
|
||||
WikiPage.create!(tag_name: tn, created_user: user, updated_user: user).tap do |p|
|
||||
Wiki::Commit.content!(page: p, body: 'init', created_user: user, message: 'init')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET /wiki' do
|
||||
|
||||
Reference in New Issue
Block a user