feat: Wiki 有無判定軽量化(#233) (#234)
#233 Backend が対応できてなかったのでそっちも対応させた. Co-authored-by: miteruzo <miteruzo@naver.com> Reviewed-on: #234
This commit was merged in pull request #234.
This commit is contained in:
@@ -54,9 +54,9 @@ RSpec.describe 'Posts API', type: :request do
|
||||
# 全postの全tagが name を含むこと
|
||||
expect(posts).not_to be_empty
|
||||
posts.each do |p|
|
||||
expect(p["tags"]).to be_an(Array)
|
||||
p["tags"].each do |t|
|
||||
expect(t).to include("name", "category")
|
||||
expect(p['tags']).to be_an(Array)
|
||||
p['tags'].each do |t|
|
||||
expect(t).to include('name', 'category', 'has_wiki')
|
||||
end
|
||||
end
|
||||
expect(json['count']).to be_an(Integer)
|
||||
@@ -71,11 +71,19 @@ RSpec.describe 'Posts API', type: :request do
|
||||
get "/posts", params: { tags: "spec_tag" }
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
ids = json.fetch("posts").map { |p| p["id"] }
|
||||
posts = json.fetch('posts')
|
||||
ids = posts.map { |p| p['id'] }
|
||||
|
||||
expect(ids).to include(hit_post.id)
|
||||
expect(ids).not_to include(miss_post.id)
|
||||
expect(json['count']).to be_an(Integer)
|
||||
|
||||
posts.each do |p|
|
||||
expect(p['tags']).to be_an(Array)
|
||||
p['tags'].each do |t|
|
||||
expect(t).to include('name', 'category', 'has_wiki')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "returns empty posts when nothing matches" do
|
||||
@@ -104,7 +112,7 @@ RSpec.describe 'Posts API', type: :request do
|
||||
|
||||
# show は build_tag_tree_for を使うので、tags はツリー形式(children 付き)
|
||||
node = json['tags'][0]
|
||||
expect(node).to include('id', 'name', 'category', 'post_count', 'children')
|
||||
expect(node).to include('id', 'name', 'category', 'post_count', 'children', 'has_wiki')
|
||||
expect(node['name']).to eq('spec_tag')
|
||||
|
||||
expect(json).to have_key('related')
|
||||
|
||||
Reference in New Issue
Block a user