Add searchability account/status.compute_searchability test
This commit is contained in:
parent
8915cb4c2b
commit
114bd48c4b
5 changed files with 180 additions and 5 deletions
|
@ -5,6 +5,113 @@ require 'rails_helper'
|
|||
RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
context 'with searchability' do
|
||||
subject { described_class.new.call('alice', 'example.com', payload) }
|
||||
|
||||
let(:software) { 'mastodon' }
|
||||
let(:searchable_by) { 'https://www.w3.org/ns/activitystreams#Public' }
|
||||
let(:sender_bio) { '' }
|
||||
let(:payload) do
|
||||
{
|
||||
id: 'https://foo.test',
|
||||
type: 'Actor',
|
||||
inbox: 'https://foo.test/inbox',
|
||||
followers: 'https://example.com/followers',
|
||||
searchableBy: searchable_by,
|
||||
summary: sender_bio,
|
||||
}.with_indifferent_access
|
||||
end
|
||||
|
||||
before do
|
||||
Fabricate(:instance_info, domain: 'example.com', software: software)
|
||||
stub_request(:get, 'https://example.com/.well-known/nodeinfo').to_return(body: '{}')
|
||||
stub_request(:get, 'https://example.com/followers').to_return(body: '[]')
|
||||
end
|
||||
|
||||
context 'when public' do
|
||||
it 'searchability is public' do
|
||||
expect(subject.searchability).to eq 'public'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when private' do
|
||||
let(:searchable_by) { 'https://example.com/followers' }
|
||||
|
||||
it 'searchability is private' do
|
||||
expect(subject.searchability).to eq 'private'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when direct' do
|
||||
let(:searchable_by) { '' }
|
||||
|
||||
it 'searchability is direct' do
|
||||
expect(subject.searchability).to eq 'direct'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when limited' do
|
||||
let(:searchable_by) { 'as:Limited' }
|
||||
|
||||
it 'searchability is limited' do
|
||||
expect(subject.searchability).to eq 'limited'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when default value' do
|
||||
let(:searchable_by) { nil }
|
||||
|
||||
it 'searchability is direct' do
|
||||
expect(subject.searchability).to eq 'direct'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when misskey user' do
|
||||
let(:software) { 'misskey' }
|
||||
let(:searchable_by) { nil }
|
||||
|
||||
it 'searchability is public' do
|
||||
expect(subject.searchability).to eq 'public'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with bio' do
|
||||
let(:searchable_by) { nil }
|
||||
|
||||
context 'with public' do
|
||||
let(:sender_bio) { '#searchable_by_all_users' }
|
||||
|
||||
it 'searchability is public' do
|
||||
expect(subject.searchability).to eq 'public'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with private' do
|
||||
let(:sender_bio) { '#searchable_by_followers_only' }
|
||||
|
||||
it 'searchability is private' do
|
||||
expect(subject.searchability).to eq 'private'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with direct' do
|
||||
let(:sender_bio) { '#searchable_by_reacted_users_only' }
|
||||
|
||||
it 'searchability is direct' do
|
||||
expect(subject.searchability).to eq 'direct'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with limited' do
|
||||
let(:sender_bio) { '#searchable_by_nobody' }
|
||||
|
||||
it 'searchability is limited' do
|
||||
expect(subject.searchability).to eq 'limited'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with property values' do
|
||||
let(:payload) do
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue