このコミットが含まれているのは:
@@ -4,9 +4,9 @@ require 'rails_helper'
|
||||
RSpec.describe 'NicoTags', type: :request do
|
||||
describe 'GET /tags/nico' do
|
||||
it 'returns paginated tags and total count' do
|
||||
create_list(:tag, 3, :nico)
|
||||
3.times { |i| create(:external_tag, name: "pagination_#{ i }") }
|
||||
|
||||
get '/tags/nico', params: { page: 2, limit: 2 }
|
||||
get '/tags/nico', params: { page: 2, limit: 2, name: 'pagination_' }
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json['tags'].size).to eq(1)
|
||||
@@ -14,12 +14,12 @@ RSpec.describe 'NicoTags', type: :request do
|
||||
end
|
||||
|
||||
it 'filters by nico tag name, linked tag name, and link status' do
|
||||
linked = create(:tag, :nico)
|
||||
linked.tag_name.update!(name: 'nico:search_linked')
|
||||
unlinked = create(:tag, :nico)
|
||||
unlinked.tag_name.update!(name: 'nico:search_unlinked')
|
||||
other = create(:tag, :nico)
|
||||
other.tag_name.update!(name: 'nico:other')
|
||||
linked = create(:external_tag)
|
||||
linked.update!(name: 'search_linked')
|
||||
unlinked = create(:external_tag)
|
||||
unlinked.update!(name: 'search_unlinked')
|
||||
other = create(:external_tag)
|
||||
other.update!(name: 'other')
|
||||
destination = create(:tag, :general)
|
||||
destination.tag_name.update!(name: 'destination_search')
|
||||
NicoTagRelation.create!(nico_tag: linked, tag: destination)
|
||||
@@ -42,26 +42,26 @@ RSpec.describe 'NicoTags', type: :request do
|
||||
end
|
||||
|
||||
it 'sorts by name and timestamps' do
|
||||
older = create(:tag, :nico)
|
||||
older.tag_name.update!(name: 'nico:a')
|
||||
older = create(:external_tag)
|
||||
older.update!(name: 'ordered_a')
|
||||
older.update_columns(created_at: 2.days.ago)
|
||||
newer = create(:tag, :nico)
|
||||
newer.tag_name.update!(name: 'nico:b')
|
||||
newer = create(:external_tag)
|
||||
newer.update!(name: 'ordered_b')
|
||||
newer.update_columns(created_at: 1.day.ago)
|
||||
older_post_tag =
|
||||
PostTag.create!(post: Post.create!(url: 'https://example.com/nico-older'), tag: older)
|
||||
PostExternalTag.create!(post: create(:post), external_tag: older)
|
||||
older_post_tag.update_columns(created_at: 1.hour.ago)
|
||||
newer_post_tag =
|
||||
PostTag.create!(post: Post.create!(url: 'https://example.com/nico-newer'), tag: newer)
|
||||
PostExternalTag.create!(post: create(:post), external_tag: newer)
|
||||
newer_post_tag.update_columns(created_at: 2.hours.ago)
|
||||
|
||||
get '/tags/nico', params: { order: 'name:desc' }
|
||||
get '/tags/nico', params: { order: 'name:desc', name: 'ordered_' }
|
||||
expect(json.fetch('tags').map { |tag| tag['id'] }).to eq([newer.id, older.id])
|
||||
|
||||
get '/tags/nico', params: { order: 'created_at:asc' }
|
||||
get '/tags/nico', params: { order: 'created_at:asc', name: 'ordered_' }
|
||||
expect(json.fetch('tags').map { |tag| tag['id'] }).to eq([older.id, newer.id])
|
||||
|
||||
get '/tags/nico', params: { order: 'updated_at:desc' }
|
||||
get '/tags/nico', params: { order: 'updated_at:desc', name: 'ordered_' }
|
||||
expect(json.fetch('tags').map { |tag| tag['id'] }).to eq([older.id, newer.id])
|
||||
expect(Time.zone.parse(json.fetch('tags').first.fetch('recent_post_tag_created_at')))
|
||||
.to be_within(1.second).of(older_post_tag.created_at)
|
||||
@@ -71,7 +71,7 @@ RSpec.describe 'NicoTags', type: :request do
|
||||
describe 'PATCH /tags/nico/:id' do
|
||||
let(:member) { create(:user, :member) }
|
||||
let(:admin) { create(:user, :admin) }
|
||||
let(:nico_tag) { create(:tag, :nico) }
|
||||
let(:nico_tag) { create(:external_tag) }
|
||||
|
||||
it '401 when not logged in' do
|
||||
sign_out
|
||||
@@ -85,18 +85,18 @@ RSpec.describe 'NicoTags', type: :request do
|
||||
expect(response).to have_http_status(:forbidden)
|
||||
end
|
||||
|
||||
it '400 when target is not nico category' do
|
||||
it '404 when only an internal tag exists for the target id' do
|
||||
sign_in_as(member)
|
||||
non_nico = create(:tag, :general)
|
||||
expect(ExternalTag.exists?(non_nico.id)).to be(false)
|
||||
patch "/tags/nico/#{non_nico.id}", params: { tags: 'a b' }
|
||||
expect(response).to have_http_status(:bad_request)
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
|
||||
it '200 and updates linked tags while recording tag versions' do
|
||||
sign_in_as(admin)
|
||||
|
||||
nico_tag_name = TagName.create!(name: 'nico:nico_tags_spec_source')
|
||||
nico_tag = Tag.create!(tag_name: nico_tag_name, category: :nico)
|
||||
nico_tag = create(:external_tag, name: 'nico_tags_spec_source')
|
||||
|
||||
linked_a_name = TagName.create!(name: 'nico_linked_a')
|
||||
linked_a = Tag.create!(tag_name: linked_a_name, category: :general)
|
||||
@@ -104,7 +104,8 @@ RSpec.describe 'NicoTags', type: :request do
|
||||
linked_b_name = TagName.create!(name: 'nico_linked_b')
|
||||
linked_b = Tag.create!(tag_name: linked_b_name, category: :general)
|
||||
|
||||
TagVersioning.ensure_snapshot!(nico_tag, created_by_user: admin)
|
||||
NicoTagVersionRecorder.record!(external_tag: nico_tag,
|
||||
event_type: :create, created_by_user: admin)
|
||||
|
||||
expect {
|
||||
patch "/tags/nico/#{nico_tag.id}", params: {
|
||||
@@ -126,26 +127,26 @@ RSpec.describe 'NicoTags', type: :request do
|
||||
expect(versions.map(&:event_type)).to eq(['create', 'update'])
|
||||
expect(versions.last.linked_tags.split).to match_array([
|
||||
'nico_linked_a',
|
||||
'nico_linked_b'
|
||||
])
|
||||
'nico_linked_b'])
|
||||
expect(versions.last.created_by_user_id).to eq(admin.id)
|
||||
end
|
||||
|
||||
it 'returns 422 when linked tag normalises to nico tag' do
|
||||
it 'clears existing links and records the empty mapping for a member' do
|
||||
sign_in_as(member)
|
||||
|
||||
other_nico = create(:tag, :nico, name: 'nico:linked_ng')
|
||||
TagName.create!(name: 'linked_ng_alias', canonical: other_nico.tag_name)
|
||||
|
||||
TagVersioning.ensure_snapshot!(nico_tag, created_by_user: member)
|
||||
linked = create(:tag)
|
||||
NicoTagRelation.insert_all!([{ nico_tag_id: nico_tag.id, tag_id: linked.id }])
|
||||
NicoTagVersionRecorder.record!(external_tag: nico_tag,
|
||||
event_type: :create, created_by_user: member)
|
||||
|
||||
expect {
|
||||
patch "/tags/nico/#{nico_tag.id}", params: { tags: 'linked_ng_alias' }
|
||||
}.not_to change(NicoTagVersion, :count)
|
||||
patch "/tags/nico/#{ nico_tag.id }", params: { tags: '' }
|
||||
}.to change(NicoTagVersion, :count).by(1)
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(json.fetch('errors')).to include(
|
||||
'tags' => ['ニコニコ・タグ同士は連携できません.'])
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json).to eq([])
|
||||
expect(nico_tag.reload.linked_tags).to be_empty
|
||||
expect(nico_tag.nico_tag_versions.order(:version_no).last)
|
||||
.to have_attributes(linked_tags: '', created_by_user: member)
|
||||
end
|
||||
|
||||
it 'returns the tags field error when a nico tag is specified directly' do
|
||||
|
||||
@@ -17,7 +17,7 @@ RSpec.describe 'Posts API', type: :request do
|
||||
end
|
||||
|
||||
def create_nico_tag!(name)
|
||||
Tag.find_or_create_by_tag_name!(name, category: :nico)
|
||||
ExternalTag.find_or_create_by!(platform: :nico, name: name.delete_prefix('nico:'))
|
||||
end
|
||||
|
||||
def dummy_upload
|
||||
@@ -1250,9 +1250,9 @@ RSpec.describe 'Posts API', type: :request do
|
||||
)
|
||||
end
|
||||
|
||||
context 'when nico tag already exists in tags' do
|
||||
context 'when the external nico tag already exists' do
|
||||
before do
|
||||
Tag.find_or_create_by_tag_name!('nico:nico_tag', category: :nico)
|
||||
create(:external_tag, name: 'nico_tag')
|
||||
end
|
||||
|
||||
it 'returns 422 with tag field errors' do
|
||||
@@ -1530,9 +1530,9 @@ RSpec.describe 'Posts API', type: :request do
|
||||
|
||||
versions = post_record.post_versions.order(:version_no)
|
||||
expect(versions.first.tags_json).to include(
|
||||
a_hash_including('id' => tag.id,
|
||||
a_hash_including('tag_id' => tag.id,
|
||||
'sections' => [{ 'begin_ms' => 1000, 'end_ms' => 2000 }]))
|
||||
expect(versions.last.tags_json.map { |item| item.fetch('id') })
|
||||
expect(versions.last.tags_json.map { |item| item.fetch('tag_id') })
|
||||
.not_to include(tag.id)
|
||||
end
|
||||
|
||||
@@ -1551,7 +1551,7 @@ RSpec.describe 'Posts API', type: :request do
|
||||
expect(PostTag.find_by!(post: post_record, tag:).created_user).to eq(member)
|
||||
expect(tag.reload.post_count).to eq(1)
|
||||
snapshots = post_record.post_versions.order(:version_no).map do |version|
|
||||
version.tags_json.map { |item| item.fetch('id') }
|
||||
version.tags_json.map { |item| item.fetch('tag_id') }
|
||||
end
|
||||
expect(snapshots.map { |ids| ids.include?(tag.id) }).to eq([true, false, true])
|
||||
end
|
||||
@@ -1576,9 +1576,9 @@ RSpec.describe 'Posts API', type: :request do
|
||||
)
|
||||
end
|
||||
|
||||
context 'when nico tag already exists in tags' do
|
||||
context 'when the external nico tag already exists' do
|
||||
before do
|
||||
Tag.find_or_create_by_tag_name!('nico:nico_tag', category: :nico)
|
||||
create(:external_tag, name: 'nico_tag')
|
||||
end
|
||||
|
||||
it 'returns 422 with tag field errors' do
|
||||
@@ -1895,7 +1895,7 @@ RSpec.describe 'Posts API', type: :request do
|
||||
base_version = create_post_version_for!(post_record.reload)
|
||||
|
||||
nico_tag = create_nico_tag!('nico:optimistic_lock_nico')
|
||||
PostTag.create!(post: post_record, tag: nico_tag, created_user: member)
|
||||
PostExternalTag.create!(post: post_record, external_tag: nico_tag)
|
||||
|
||||
PostVersionRecorder.record!(
|
||||
post: post_record.reload,
|
||||
@@ -1915,14 +1915,14 @@ RSpec.describe 'Posts API', type: :request do
|
||||
|
||||
expect(names).to include('spec_tag')
|
||||
expect(names).to include(Tag.no_deerjikist.name)
|
||||
expect(names).to include(nico_tag.name)
|
||||
expect(post_record.external_tags).to contain_exactly(nico_tag)
|
||||
end
|
||||
|
||||
it 'keeps nico tags even when they are not included in PUT tags' do
|
||||
sign_in_as(member)
|
||||
|
||||
nico_tag = create_nico_tag!('nico:readonly_update_nico')
|
||||
PostTag.create!(post: post_record, tag: nico_tag, created_user: member)
|
||||
PostExternalTag.create!(post: post_record, external_tag: nico_tag)
|
||||
|
||||
base_version = create_post_version_for!(post_record.reload)
|
||||
|
||||
@@ -1937,7 +1937,7 @@ RSpec.describe 'Posts API', type: :request do
|
||||
|
||||
expect(names).to include('spec_tag')
|
||||
expect(names).to include(Tag.no_deerjikist.name)
|
||||
expect(names).to include(nico_tag.name)
|
||||
expect(post_record.external_tags).to contain_exactly(nico_tag)
|
||||
end
|
||||
|
||||
it 'allows non-nico tags linked from nico tags to be removed by normal post update' do
|
||||
@@ -1947,7 +1947,7 @@ RSpec.describe 'Posts API', type: :request do
|
||||
linked_tag = Tag.find_or_create_by_tag_name!('relation_linked_tag', category: :general)
|
||||
|
||||
NicoTagRelation.create!(nico_tag:, tag: linked_tag)
|
||||
PostTag.create!(post: post_record, tag: nico_tag, created_user: member)
|
||||
PostExternalTag.create!(post: post_record, external_tag: nico_tag)
|
||||
PostTag.create!(post: post_record, tag: linked_tag, created_user: member)
|
||||
|
||||
base_version = create_post_version_for!(post_record.reload)
|
||||
@@ -1961,7 +1961,7 @@ RSpec.describe 'Posts API', type: :request do
|
||||
|
||||
names = post_record.reload.tags.map(&:name)
|
||||
|
||||
expect(names).to include(nico_tag.name)
|
||||
expect(post_record.external_tags).to contain_exactly(nico_tag)
|
||||
expect(names).to include('spec_tag')
|
||||
expect(names).to include(Tag.no_deerjikist.name)
|
||||
expect(names).not_to include(linked_tag.name)
|
||||
@@ -2180,6 +2180,34 @@ RSpec.describe 'Posts API', type: :request do
|
||||
expect(first.fetch('created_at')).to eq(t_v1.iso8601)
|
||||
end
|
||||
|
||||
it 'does not treat an external id as the internal tag filter' do
|
||||
external_post = create(:post)
|
||||
external = create(:external_tag, id: tag.id)
|
||||
PostExternalTag.create!(post: external_post, external_tag: external)
|
||||
PostVersionRecorder.record!(post: external_post,
|
||||
event_type: :create, created_by_user: member)
|
||||
|
||||
get '/posts/versions', params: { post: external_post.id, tag: tag.id }
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json.fetch('versions')).to be_empty
|
||||
expect(json.fetch('count')).to eq(0)
|
||||
end
|
||||
|
||||
it 'can render history containing external identifiers' do
|
||||
PostExternalTag.create!(post: post_record, external_tag: create(:external_tag))
|
||||
post_record.update_columns(version_no: 2)
|
||||
PostVersionRecorder.record!(post: post_record,
|
||||
event_type: :update, created_by_user: member)
|
||||
|
||||
get '/posts/versions', params: { post: post_record.id }
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json.fetch('count')).to eq(3)
|
||||
expect(json.fetch('versions').first.fetch('tags')).to include(
|
||||
'name' => tag2.name, 'type' => 'context')
|
||||
end
|
||||
|
||||
it 'filters versions by tag when the current snapshot includes the tag' do
|
||||
get '/posts/versions', params: { post: post_record.id, tag: tag2.id }
|
||||
|
||||
|
||||
@@ -80,38 +80,6 @@ RSpec.describe "TagChildren", type: :request do
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when parent is nico' do
|
||||
before { stub_current_user(admin) }
|
||||
|
||||
let!(:parent) { create(:tag, :nico, name: 'nico:parent_ng') }
|
||||
let(:parent_id) { parent.id }
|
||||
let(:child_id) { child.id }
|
||||
|
||||
it 'returns 400 and does not create relation' do
|
||||
expect {
|
||||
do_request
|
||||
}.not_to change(TagImplication, :count)
|
||||
|
||||
expect(response).to have_http_status(:bad_request)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when child is nico' do
|
||||
before { stub_current_user(admin) }
|
||||
|
||||
let!(:child) { create(:tag, :nico, name: 'nico:child_ng') }
|
||||
let(:parent_id) { parent.id }
|
||||
let(:child_id) { child.id }
|
||||
|
||||
it 'returns 400 and does not create relation' do
|
||||
expect {
|
||||
do_request
|
||||
}.not_to change(TagImplication, :count)
|
||||
|
||||
expect(response).to have_http_status(:bad_request)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE /tag_children" do
|
||||
@@ -186,31 +154,5 @@ RSpec.describe "TagChildren", type: :request do
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when parent is nico' do
|
||||
before { stub_current_user(admin) }
|
||||
|
||||
let!(:parent) { create(:tag, :nico, name: 'nico:parent_ng_delete') }
|
||||
let(:parent_id) { parent.id }
|
||||
let(:child_id) { child.id }
|
||||
|
||||
it 'returns 400' do
|
||||
do_request
|
||||
expect(response).to have_http_status(:bad_request)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when child is nico' do
|
||||
before { stub_current_user(admin) }
|
||||
|
||||
let!(:child) { create(:tag, :nico, name: 'nico:child_ng_delete') }
|
||||
let(:parent_id) { parent.id }
|
||||
let(:child_id) { child.id }
|
||||
|
||||
it 'returns 400' do
|
||||
do_request
|
||||
expect(response).to have_http_status(:bad_request)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -164,20 +164,14 @@ RSpec.describe 'Tags API', type: :request do
|
||||
Tag.create!(tag_name: TagName.create!(name: 'cat_general'), category: :general)
|
||||
Tag.create!(tag_name: TagName.create!(name: 'cat_material'), category: :material)
|
||||
Tag.create!(tag_name: TagName.create!(name: 'cat_meta'), category: :meta)
|
||||
Tag.create!(tag_name: TagName.create!(name: 'nico:cat_nico'), category: :nico)
|
||||
create(:external_tag, name: 'cat_nico')
|
||||
|
||||
get '/tags', params: { name: 'cat_', order: 'category:asc', limit: 20 }
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(response_names).to eq(%w[
|
||||
cat_deerjikist
|
||||
cat_meme
|
||||
cat_character
|
||||
cat_general
|
||||
cat_material
|
||||
cat_meta
|
||||
nico:cat_nico
|
||||
])
|
||||
expect(response_names).to eq([
|
||||
'cat_deerjikist', 'cat_meme', 'cat_character',
|
||||
'cat_general', 'cat_material', 'cat_meta'])
|
||||
end
|
||||
|
||||
it 'paginates and keeps total count' do
|
||||
@@ -299,6 +293,82 @@ RSpec.describe 'Tags API', type: :request do
|
||||
end
|
||||
|
||||
describe 'GET /tags/autocomplete' do
|
||||
it 'combines internal and external matches without conflating equal ids' do
|
||||
internal = Tag.create!(category: :general, name: 'mixed_internal', post_count: 2)
|
||||
external = create(:external_tag, id: internal.id,
|
||||
name: 'mixed_external', post_count: 3)
|
||||
|
||||
get '/tags/autocomplete', params: { q: 'not:mixed' }
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json.map { |row| row.fetch('name') })
|
||||
.to eq(['nico:mixed_external', 'mixed_internal'])
|
||||
expect(json.first).to include(
|
||||
'id' => external.id, 'category' => 'nico', 'post_count' => 3,
|
||||
'deprecated_at' => nil, 'matched_alias' => nil)
|
||||
expect(json.first.fetch('updated_at')).to eq(json.first.fetch('created_at'))
|
||||
end
|
||||
|
||||
it 'matches an external tag by its platform prefix' do
|
||||
create(:external_tag, name: 'prefix_match', post_count: 1)
|
||||
|
||||
get '/tags/autocomplete', params: { q: 'nico:prefix' }
|
||||
|
||||
expect(json.map { |row| row.fetch('name') }).to eq(['nico:prefix_match'])
|
||||
end
|
||||
|
||||
it 'excludes unused external tags unless present is false' do
|
||||
create(:external_tag, name: 'unused_external')
|
||||
|
||||
get '/tags/autocomplete', params: { q: 'unused' }
|
||||
expect(json).to be_empty
|
||||
|
||||
get '/tags/autocomplete', params: { q: 'unused', present: '0' }
|
||||
expect(json.map { |row| row.fetch('name') }).to eq(['nico:unused_external'])
|
||||
end
|
||||
|
||||
it 'limits the combined results to 20 and sorts ties by displayed name' do
|
||||
11.times do |i|
|
||||
name = "combined_#{ i.to_s.rjust(2, '0') }"
|
||||
Tag.create!(category: :general, name:, post_count: 1)
|
||||
create(:external_tag, name:, post_count: 1)
|
||||
end
|
||||
|
||||
get '/tags/autocomplete', params: { q: 'combined' }
|
||||
|
||||
expected = 11.times.map { |i| "combined_#{ i.to_s.rjust(2, '0') }" }
|
||||
expected += expected.map { |name| "nico:#{ name }" }
|
||||
expect(json.map { |row| row.fetch('name') }).to eq(expected.first(20))
|
||||
end
|
||||
|
||||
it 'excludes external and alias-only matches when nico is false' do
|
||||
internal = Tag.create!(category: :general, name: 'switch_internal', post_count: 1)
|
||||
alias_target = Tag.create!(category: :general, name: 'alias_target', post_count: 1)
|
||||
TagName.create!(name: 'switch_alias', canonical: alias_target.tag_name)
|
||||
create(:external_tag, name: 'switch_external', post_count: 1)
|
||||
|
||||
get '/tags/autocomplete', params: { q: 'switch', nico: '0' }
|
||||
|
||||
expect(json.map { |row| row.fetch('id') }).to eq([internal.id])
|
||||
end
|
||||
|
||||
['%', '_'].each do |wildcard|
|
||||
it "treats #{ wildcard } literally for canonical, alias, and external names" do
|
||||
literal = "literal#{ wildcard }match"
|
||||
Tag.create!(category: :general, name: literal, post_count: 1)
|
||||
alias_target = Tag.create!(category: :general, name: 'literal_alias_target', post_count: 1)
|
||||
TagName.create!(name: "#{ literal }_alias", canonical: alias_target.tag_name)
|
||||
create(:external_tag, name: literal, post_count: 1)
|
||||
Tag.create!(category: :general, name: 'literalXmatch', post_count: 2)
|
||||
create(:external_tag, name: 'literalXmatch', post_count: 2)
|
||||
|
||||
get '/tags/autocomplete', params: { q: "literal#{ wildcard }" }
|
||||
|
||||
expect(json.map { |row| row.fetch('name') })
|
||||
.to contain_exactly(literal, alias_target.name, "nico:#{ literal }")
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns matching tags by q' do
|
||||
get '/tags/autocomplete', params: { q: 'spec' }
|
||||
|
||||
@@ -487,18 +557,6 @@ RSpec.describe 'Tags API', type: :request do
|
||||
expect(json.fetch('deprecated_at')).to be_present
|
||||
end
|
||||
|
||||
it 'rejects deprecating a nico tag' do
|
||||
nico_tag = Tag.create!(name: 'nico:deprecated_update', category: :nico)
|
||||
|
||||
patch "/tags/#{ nico_tag.id }", params: { deprecated: '1' }
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(nico_tag.reload.deprecated_at).to be_nil
|
||||
expect(json.fetch('errors')).to include(
|
||||
'deprecated' => ['ニコタグは廃止できません.']
|
||||
)
|
||||
end
|
||||
|
||||
it 'returns 422 when changing normal tag category to nico' do
|
||||
expect {
|
||||
patch "/tags/#{tag.id}", params: { category: 'nico' }
|
||||
@@ -508,32 +566,6 @@ RSpec.describe 'Tags API', type: :request do
|
||||
expect(tag.reload.category).to eq('general')
|
||||
end
|
||||
|
||||
it 'returns 422 when updating nico tag name' do
|
||||
nico_tag_name = TagName.create!(name: 'nico:tags_spec_source')
|
||||
nico_tag = Tag.create!(tag_name: nico_tag_name, category: :nico)
|
||||
|
||||
expect {
|
||||
patch "/tags/#{ nico_tag.id }", params: { name: 'nico:tags_spec_renamed' }
|
||||
}.not_to change(NicoTagVersion, :count)
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
|
||||
expect(nico_tag.reload.name).to eq('nico:tags_spec_source')
|
||||
expect(nico_tag.category).to eq('nico')
|
||||
end
|
||||
|
||||
it 'returns 422 when changing nico tag category to normal category' do
|
||||
nico_tag_name = TagName.create!(name: 'nico:category_change_ng')
|
||||
nico_tag = Tag.create!(tag_name: nico_tag_name, category: :nico)
|
||||
|
||||
expect {
|
||||
patch "/tags/#{nico_tag.id}", params: { category: 'general' }
|
||||
}.not_to change(NicoTagVersion, :count)
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(nico_tag.reload.category).to eq('nico')
|
||||
end
|
||||
|
||||
it 'PATCH で tag の name を変更すると対応する wiki version を作成する' do
|
||||
wiki_page =
|
||||
Wiki::Commit.create_content!(
|
||||
@@ -1169,28 +1201,6 @@ RSpec.describe 'Tags API', type: :request do
|
||||
expect(tag.category).to eq('general')
|
||||
end
|
||||
|
||||
it 'nico tag は更新できない' do
|
||||
nico_tag = Tag.create!(
|
||||
tag_name: TagName.create!(name: 'nico:put_update_all_ng'),
|
||||
category: :nico
|
||||
)
|
||||
|
||||
expect {
|
||||
put "/tags/#{ nico_tag.id }", params: {
|
||||
name: 'nico:put_update_all_renamed',
|
||||
category: 'nico',
|
||||
aliases: '',
|
||||
parent_tags: '',
|
||||
deprecated: '0',
|
||||
}
|
||||
}.not_to change(NicoTagVersion, :count)
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
|
||||
expect(nico_tag.reload.name).to eq('nico:put_update_all_ng')
|
||||
expect(nico_tag.category).to eq('nico')
|
||||
end
|
||||
|
||||
it 'system tag の name は変更できない' do
|
||||
system_tag = Tag.tagme
|
||||
old_name = system_tag.name
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする