1
0
mirror of https://github.com/mastodon/mastodon synced 2024-12-12 21:58:20 +09:00

Add test coverage to ActivityPub::TagManager

This commit is contained in:
Claire 2024-11-04 17:25:15 +01:00
parent 5684d666a9
commit df91732b9b

View File

@ -7,17 +7,50 @@ RSpec.describe ActivityPub::TagManager do
subject { described_class.instance } subject { described_class.instance }
let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http'}://#{Rails.configuration.x.web_domain}" }
describe '#public_collection?' do
it 'returns true for the special public collection and common shorthands' do
expect(subject.public_collection?('https://www.w3.org/ns/activitystreams#Public')).to be true
expect(subject.public_collection?('as:Public')).to be true
expect(subject.public_collection?('Public')).to be true
end
it 'returns false for other URIs' do
expect(subject.public_collection?('https://example.com/foo/bar')).to be false
end
end
describe '#url_for' do describe '#url_for' do
it 'returns a string' do it 'returns a string starting with web domain' do
account = Fabricate(:account) account = Fabricate(:account)
expect(subject.url_for(account)).to be_a String expect(subject.url_for(account)).to be_a(String)
.and start_with(domain)
end end
end end
describe '#uri_for' do describe '#uri_for' do
it 'returns a string' do it 'returns a string starting with web domain' do
account = Fabricate(:account) account = Fabricate(:account)
expect(subject.uri_for(account)).to be_a String expect(subject.uri_for(account)).to be_a(String)
.and start_with(domain)
end
end
describe '#activity_uri_for' do
context 'when given an account' do
it 'raises an exception' do
account = Fabricate(:account)
expect { subject.activity_uri_for(account) }.to raise_error(ArgumentError)
end
end
context 'when given a local activity' do
it 'returns a string starting with web domain' do
status = Fabricate(:status)
expect(subject.uri_for(status)).to be_a(String)
.and start_with(domain)
end
end end
end end