@@ -56,6 +56,17 @@ RSpec.describe "TagChildren", type: :request do
|
||||
|
||||
expect(response).to have_http_status(:no_content)
|
||||
end
|
||||
|
||||
it 'returns 422 and does not create relation when the new link makes a cycle' do
|
||||
TagImplication.create!(tag: parent, parent_tag: child)
|
||||
|
||||
expect {
|
||||
do_request
|
||||
}.not_to change(TagImplication, :count)
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(TagImplication.where(tag: child, parent_tag: parent)).not_to exist
|
||||
end
|
||||
end
|
||||
|
||||
context "when Tag.find raises (invalid ids)" do
|
||||
|
||||
@@ -797,7 +797,17 @@ RSpec.describe 'Tags API', type: :request do
|
||||
)
|
||||
TagImplication.create!(tag: first, parent_tag: root_material)
|
||||
TagImplication.create!(tag: second, parent_tag: first)
|
||||
TagImplication.create!(tag: first, parent_tag: second)
|
||||
now = Time.current
|
||||
TagImplication.insert_all!(
|
||||
[
|
||||
{
|
||||
tag_id: first.id,
|
||||
parent_tag_id: second.id,
|
||||
created_at: now,
|
||||
updated_at: now
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
get '/tags/with-depth', params: { parent: root_material.id }
|
||||
|
||||
@@ -1364,8 +1374,6 @@ RSpec.describe 'Tags API', type: :request do
|
||||
end
|
||||
|
||||
it 'parent_tags に指定すると循環する tag は 422 にする' do
|
||||
pending '#332 で対応予定'
|
||||
|
||||
child = Tag.create!(
|
||||
tag_name: TagName.create!(name: 'put_cycle_child'),
|
||||
category: :general
|
||||
|
||||
新しい課題から参照
ユーザをブロックする