The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

46 lines
1.4 KiB

  1. require 'rails_helper'
  2. describe WellKnown::WebfingerController, type: :controller do
  3. render_views
  4. describe 'GET #show' do
  5. let(:alice) { Fabricate(:account, username: 'alice') }
  6. around(:each) do |example|
  7. before = Rails.configuration.x.alternate_domains
  8. example.run
  9. Rails.configuration.x.alternate_domains = before
  10. end
  11. it 'returns http success when account can be found' do
  12. get :show, params: { resource: alice.to_webfinger_s }, format: :json
  13. expect(response).to have_http_status(:success)
  14. end
  15. it 'returns http not found when account cannot be found' do
  16. get :show, params: { resource: 'acct:not@existing.com' }, format: :json
  17. expect(response).to have_http_status(:not_found)
  18. end
  19. it 'returns http success when account can be found with alternate domains' do
  20. Rails.configuration.x.alternate_domains = ["foo.org"]
  21. username, domain = alice.to_webfinger_s.split("@")
  22. get :show, params: { resource: "#{username}@foo.org" }, format: :json
  23. expect(response).to have_http_status(:success)
  24. end
  25. it 'returns http not found when account can not be found with alternate domains' do
  26. Rails.configuration.x.alternate_domains = ["foo.org"]
  27. username, domain = alice.to_webfinger_s.split("@")
  28. get :show, params: { resource: "#{username}@bar.org" }, format: :json
  29. expect(response).to have_http_status(:not_found)
  30. end
  31. end
  32. end