ec2b3d2254
Reviewed-on: #379 Co-authored-by: miteruzo <miteruzo@naver.com> Co-committed-by: miteruzo <miteruzo@naver.com>
34 行
1.2 KiB
Ruby
34 行
1.2 KiB
Ruby
require 'rails_helper'
|
|
|
|
|
|
RSpec.describe 'Gekanator posts API', type: :request do
|
|
describe 'GET /gekanator/posts' do
|
|
it 'omits deprecated tags and returns the stored similarity cosine' do
|
|
active_tag = Tag.create!(name: 'active tag', category: :general)
|
|
deprecated_tag = Tag.create!(
|
|
name: 'deprecated tag',
|
|
category: :general,
|
|
deprecated_at: Time.current
|
|
)
|
|
post_record = Post.create!(title: 'source', url: 'https://example.com/source')
|
|
target_post = Post.create!(title: 'target', url: 'https://example.com/target')
|
|
|
|
PostTag.create!(post: post_record, tag: active_tag)
|
|
PostTag.create!(post: post_record, tag: deprecated_tag)
|
|
PostTag.create!(post: target_post, tag: deprecated_tag)
|
|
PostSimilarity.create!(post: post_record, target_post:, cos: 0.375)
|
|
|
|
get '/gekanator/posts'
|
|
|
|
expect(response).to have_http_status(:ok)
|
|
|
|
post_json = json.fetch('posts').find { |post| post.fetch('id') == post_record.id }
|
|
expect(post_json.fetch('tags').map { |tag| tag.fetch('name') }).to eq(['active tag'])
|
|
expect(post_json.fetch('post_similarity_edges')).to contain_exactly(
|
|
'target_post_id' => target_post.id,
|
|
'cos' => 0.375
|
|
)
|
|
end
|
|
end
|
|
end
|