0
0
Fork 0

Clean up generation of account webfinger string (#1477)

* Consolidate webfinger string creation under Account#to_webfinger_s

* Introduce Account#local_username_and_domain for consolidation
This commit is contained in:
Matt Jankowski 2017-04-10 16:58:06 -04:00 committed by Eugen
parent 64dbde0dbf
commit 0687ab8ae3
9 changed files with 39 additions and 7 deletions

View file

@ -14,7 +14,7 @@ RSpec.describe XrdController, type: :controller do
let(:alice) { Fabricate(:account, username: 'alice') }
it 'returns http success when account can be found' do
get :webfinger, params: { resource: "acct:#{alice.username}@#{Rails.configuration.x.local_domain}" }
get :webfinger, params: { resource: alice.to_webfinger_s }
expect(response).to have_http_status(:success)
end

View file

@ -54,6 +54,30 @@ RSpec.describe Account, type: :model do
end
end
describe 'Local domain user methods' do
around do |example|
before = Rails.configuration.x.local_domain
example.run
Rails.configuration.x.local_domain = before
end
describe '#to_webfinger_s' do
it 'returns a webfinger string for the account' do
Rails.configuration.x.local_domain = 'example.com'
expect(subject.to_webfinger_s).to eq 'acct:alice@example.com'
end
end
describe '#local_username_and_domain' do
it 'returns the username and local domain for the account' do
Rails.configuration.x.local_domain = 'example.com'
expect(subject.local_username_and_domain).to eq 'alice@example.com'
end
end
end
describe '#acct' do
it 'returns username for local users' do
expect(subject.acct).to eql 'alice'