このコミットが含まれているのは:
@@ -0,0 +1,35 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe NicoTagRelation, type: :model do
|
||||
it 'accepts an ExternalTag regardless of its platform' do
|
||||
id = ExternalTag.maximum(:id).to_i + 10_000
|
||||
|
||||
ExternalTag.insert_all!([
|
||||
{ id:,
|
||||
platform: 'spec_external',
|
||||
name: 'external_name',
|
||||
post_count: 0,
|
||||
created_at: Time.current }])
|
||||
|
||||
external_tag = ExternalTag.find(id)
|
||||
tag = create(:tag)
|
||||
|
||||
expect(external_tag.platform_before_type_cast).to eq('spec_external')
|
||||
expect {
|
||||
described_class.create!(nico_tag: external_tag, tag:)
|
||||
}.to change(described_class, :count).by(1)
|
||||
expect(tag.linked_nico_tags).to contain_exactly(external_tag)
|
||||
end
|
||||
|
||||
it 'rejects an internal Tag through the external association type' do
|
||||
expect {
|
||||
described_class.new(nico_tag: create(:tag), tag: create(:tag))
|
||||
}.to raise_error(ActiveRecord::AssociationTypeMismatch)
|
||||
end
|
||||
|
||||
it 'rejects an ExternalTag through the internal association type' do
|
||||
expect {
|
||||
described_class.new(nico_tag: create(:external_tag), tag: create(:external_tag))
|
||||
}.to raise_error(ActiveRecord::AssociationTypeMismatch)
|
||||
end
|
||||
end
|
||||
@@ -14,13 +14,6 @@ RSpec.describe Tag, type: :model do
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns external records from the legacy nico_tags entrypoint' do
|
||||
external = create(:external_tag)
|
||||
create(:tag)
|
||||
|
||||
expect(described_class.nico_tags.where(id: external.id)).to contain_exactly(external)
|
||||
end
|
||||
|
||||
it 'finds external links by the internal tag id even when ids differ' do
|
||||
tag = create(:tag)
|
||||
external = create(:external_tag, id: tag.id + 10_000)
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする