summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMatt Jankowski <mjankowski@thoughtbot.com>2017-04-10 16:58:06 -0400
committerEugen <eugen@zeonfederated.com>2017-04-10 22:58:06 +0200
commit0687ab8ae3c2573ba2aa1d37f62e3583d0c7ab01 (patch)
tree24ea1de1856ec7f203f6f89c5b8231a5d37da2cb /spec
parent64dbde0dbf8c5d3ce820f780644d46a6b18e6743 (diff)
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
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/xrd_controller_spec.rb2
-rw-r--r--spec/models/account_spec.rb24
2 files changed, 25 insertions, 1 deletions
diff --git a/spec/controllers/xrd_controller_spec.rb b/spec/controllers/xrd_controller_spec.rb
index e687cf9e0c0..b56c68f5c3f 100644
--- a/spec/controllers/xrd_controller_spec.rb
+++ b/spec/controllers/xrd_controller_spec.rb
@@ -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
diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb
index 0c3b2b04282..0906bb0ae15 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'