Reviewed-on: #365 Co-authored-by: miteruzo <miteruzo@naver.com> Co-committed-by: miteruzo <miteruzo@naver.com>
このコミットはPull リクエスト #365 でマージされました.
このコミットが含まれているのは:
@@ -275,7 +275,7 @@ 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' do
|
||||
it 'returns at most two accepted user_suggested post_similarity questions without duplicates' do
|
||||
sign_in_as admin
|
||||
|
||||
low = create_post_similarity_question!(
|
||||
@@ -295,15 +295,14 @@ RSpec.describe 'Gekanator learning API', type: :request do
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json['questions'].length).to eq(2)
|
||||
expect(json['questions'].map { _1['id'] }).to eq([high.id, middle.id])
|
||||
expect(json['questions'].map { _1['id'] }).not_to include(low.id)
|
||||
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]))
|
||||
end
|
||||
|
||||
it 'does not return questions that already have an example for the correct post' do
|
||||
it 'can return questions that already have an example for the correct post' do
|
||||
sign_in_as admin
|
||||
|
||||
existing = create_post_similarity_question!(text: 'already learned?')
|
||||
fresh = create_post_similarity_question!(text: 'fresh?')
|
||||
|
||||
GekanatorQuestionExample.create!(
|
||||
gekanator_question: existing,
|
||||
@@ -317,15 +316,13 @@ RSpec.describe 'Gekanator learning API', type: :request do
|
||||
get "/gekanator/games/#{game.id}/extra_questions"
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json['questions'].map { _1['id'] }).to include(fresh.id)
|
||||
expect(json['questions'].map { _1['id'] }).not_to include(existing.id)
|
||||
expect(json['questions'].map { _1['id'] }).to include(existing.id)
|
||||
end
|
||||
|
||||
it 'does not return questions already asked in the game using snake_case question_id' do
|
||||
it 'can return questions already asked in the game using snake_case question_id' do
|
||||
sign_in_as admin
|
||||
|
||||
asked = create_post_similarity_question!(text: 'already asked?')
|
||||
fresh = create_post_similarity_question!(text: 'fresh?')
|
||||
game.update!(
|
||||
answers: [
|
||||
{
|
||||
@@ -338,15 +335,13 @@ RSpec.describe 'Gekanator learning API', type: :request do
|
||||
get "/gekanator/games/#{game.id}/extra_questions"
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json['questions'].map { _1['id'] }).to include(fresh.id)
|
||||
expect(json['questions'].map { _1['id'] }).not_to include(asked.id)
|
||||
expect(json['questions'].map { _1['id'] }).to include(asked.id)
|
||||
end
|
||||
|
||||
it 'does not return questions already asked in the game using camelCase questionId' do
|
||||
it 'can return questions already asked in the game using camelCase questionId' do
|
||||
sign_in_as admin
|
||||
|
||||
asked = create_post_similarity_question!(text: 'already asked?')
|
||||
fresh = create_post_similarity_question!(text: 'fresh?')
|
||||
game.update!(
|
||||
answers: [
|
||||
{
|
||||
@@ -359,8 +354,7 @@ RSpec.describe 'Gekanator learning API', type: :request do
|
||||
get "/gekanator/games/#{game.id}/extra_questions"
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json['questions'].map { _1['id'] }).to include(fresh.id)
|
||||
expect(json['questions'].map { _1['id'] }).not_to include(asked.id)
|
||||
expect(json['questions'].map { _1['id'] }).to include(asked.id)
|
||||
end
|
||||
|
||||
it 'does not return non-accepted, non-user_suggested, or non-post_similarity questions' do
|
||||
@@ -584,5 +578,35 @@ RSpec.describe 'Gekanator learning API', type: :request do
|
||||
other_post.id.to_s => 'no'
|
||||
)
|
||||
end
|
||||
|
||||
it 'normalizes legacy title length questions' do
|
||||
sign_in_as admin
|
||||
|
||||
GekanatorQuestion.create!(
|
||||
text: '題名が長めの投稿?',
|
||||
kind: 'title',
|
||||
source: 'admin_curated',
|
||||
status: 'accepted',
|
||||
priority_weight: 1.0,
|
||||
condition: {
|
||||
type: 'title-length-greater-than',
|
||||
length: 20
|
||||
},
|
||||
created_by: admin
|
||||
)
|
||||
|
||||
get '/gekanator/questions'
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
question_json = json['questions'].find { _1['id'] == 'title:length-at-least:21' }
|
||||
expect(question_json).to include(
|
||||
'text' => 'タイトルは 21 文字以上?',
|
||||
'kind' => 'title'
|
||||
)
|
||||
expect(question_json['condition']).to include(
|
||||
'type' => 'title-length-at-least',
|
||||
'length' => 21
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
新しい課題から参照
ユーザをブロックする