このコミットが含まれているのは:
2026-06-18 00:59:48 +09:00
コミット 3f1c6c135b
7個のファイルの変更987行の追加224行の削除
+1 -1
ファイルの表示
@@ -50,7 +50,7 @@ class GekanatorGamesController < ApplicationController
questions,
post_id: game.correct_post_id,
user: current_user,
limit: 2)
limit: 6)
render json: {
questions: selected.map { |question| extra_question_json(question) }
+39 -8
ファイルの表示
@@ -475,28 +475,59 @@ RSpec.describe 'Gekanator learning API', type: :request do
end
describe 'GET /gekanator/games/:id/extra_questions' do
it 'returns at most two accepted user_suggested post_similarity questions without duplicates' do
it 'returns at most six accepted user_suggested post_similarity questions without duplicates' do
sign_in_as admin
lowest = create_post_similarity_question!(
text: 'lowest?',
priority_weight: 0.5
)
low = create_post_similarity_question!(
text: 'low?',
priority_weight: 1.0
)
high = create_post_similarity_question!(
text: 'high?',
priority_weight: 3.0
)
middle = create_post_similarity_question!(
text: 'middle?',
priority_weight: 1.5
)
medium_high = create_post_similarity_question!(
text: 'medium high?',
priority_weight: 2.0
)
high = create_post_similarity_question!(
text: 'high?',
priority_weight: 2.5
)
higher = create_post_similarity_question!(
text: 'higher?',
priority_weight: 2.8
)
highest = create_post_similarity_question!(
text: 'highest?',
priority_weight: 3.0
)
overflow = create_post_similarity_question!(
text: 'overflow?',
priority_weight: 2.2
)
get "/gekanator/games/#{game.id}/extra_questions"
expect(response).to have_http_status(:ok)
expect(json['questions'].length).to eq(2)
expect(json['questions'].map { _1['id'] }.uniq.length).to eq(2)
expect(json['questions'].map { _1['id'] }).to all(be_in([low.id, high.id, middle.id]))
expect(json['questions'].length).to eq(6)
expect(json['questions'].map { _1['id'] }.uniq.length).to eq(6)
expect(json['questions'].map { _1['id'] }).to all(
be_in([
lowest.id,
low.id,
middle.id,
medium_high.id,
high.id,
higher.id,
highest.id,
overflow.id,
])
)
end
it 'can return questions that already have an example for the correct post' do