Combine repeated subject in ap fetch remote account service spec (#28952)
This commit is contained in:
parent
5119fbc9b7
commit
239244e2ed
1 changed files with 25 additions and 70 deletions
|
@ -21,20 +21,14 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
||||||
let(:account) { subject.call('https://example.com/alice', id: true) }
|
let(:account) { subject.call('https://example.com/alice', id: true) }
|
||||||
|
|
||||||
shared_examples 'sets profile data' do
|
shared_examples 'sets profile data' do
|
||||||
it 'returns an account' do
|
it 'returns an account with expected details' do
|
||||||
expect(account).to be_an Account
|
expect(account)
|
||||||
end
|
.to be_an(Account)
|
||||||
|
.and have_attributes(
|
||||||
it 'sets display name' do
|
display_name: eq('Alice'),
|
||||||
expect(account.display_name).to eq 'Alice'
|
note: eq('Foo bar'),
|
||||||
end
|
url: eq('https://example.com/alice')
|
||||||
|
)
|
||||||
it 'sets note' do
|
|
||||||
expect(account.note).to eq 'Foo bar'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets URL' do
|
|
||||||
expect(account.url).to eq 'https://example.com/alice'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -48,18 +42,11 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
||||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fetches resource' do
|
it 'fetches resource and looks up webfinger and returns nil' do
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns nil' do
|
|
||||||
expect(account).to be_nil
|
expect(account).to be_nil
|
||||||
|
|
||||||
|
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
||||||
|
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -71,17 +58,12 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
||||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fetches resource' do
|
it 'fetches resource and looks up webfinger and sets attributes' do
|
||||||
account
|
account
|
||||||
|
|
||||||
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets username and domain from webfinger' do
|
|
||||||
expect(account.username).to eq 'alice'
|
expect(account.username).to eq 'alice'
|
||||||
expect(account.domain).to eq 'example.com'
|
expect(account.domain).to eq 'example.com'
|
||||||
end
|
end
|
||||||
|
@ -98,22 +80,13 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
||||||
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fetches resource' do
|
it 'fetches resource and looks up webfinger and follows redirection and sets attributes' do
|
||||||
account
|
account
|
||||||
|
|
||||||
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up "redirected" webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
|
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets username and domain from final webfinger' do
|
|
||||||
expect(account.username).to eq 'alice'
|
expect(account.username).to eq 'alice'
|
||||||
expect(account.domain).to eq 'iscool.af'
|
expect(account.domain).to eq 'iscool.af'
|
||||||
end
|
end
|
||||||
|
@ -129,18 +102,11 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
||||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fetches resource' do
|
it 'fetches resource and looks up webfinger and does not create account' do
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not create account' do
|
|
||||||
expect(account).to be_nil
|
expect(account).to be_nil
|
||||||
|
|
||||||
|
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
||||||
|
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -153,23 +119,12 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
||||||
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fetches resource' do
|
it 'fetches resource and looks up webfinger and follows redirect and does not create account' do
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up "redirected" webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not create account' do
|
|
||||||
expect(account).to be_nil
|
expect(account).to be_nil
|
||||||
|
|
||||||
|
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
||||||
|
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
||||||
|
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue