From 0687ab8ae3c2573ba2aa1d37f62e3583d0c7ab01 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 10 Apr 2017 16:58:06 -0400 Subject: 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 --- spec/models/account_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'spec/models') diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 0c3b2b042..0906bb0ae 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -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' -- cgit