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.

67 lines
1.4 KiB

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe RemoteFollow do
  4. before do
  5. stub_request(:get, 'https://quitter.no/.well-known/webfinger?resource=acct:gargron@quitter.no').to_return(request_fixture('webfinger.txt'))
  6. end
  7. let(:attrs) { nil }
  8. let(:remote_follow) { described_class.new(attrs) }
  9. describe '.initialize' do
  10. subject { remote_follow.acct }
  11. context 'attrs with acct' do
  12. let(:attrs) { { acct: 'gargron@quitter.no' } }
  13. it 'returns acct' do
  14. is_expected.to eq 'gargron@quitter.no'
  15. end
  16. end
  17. context 'attrs without acct' do
  18. let(:attrs) { {} }
  19. it do
  20. is_expected.to be_nil
  21. end
  22. end
  23. end
  24. describe '#valid?' do
  25. subject { remote_follow.valid? }
  26. context 'attrs with acct' do
  27. let(:attrs) { { acct: 'gargron@quitter.no' }}
  28. it do
  29. is_expected.to be true
  30. end
  31. end
  32. context 'attrs without acct' do
  33. let(:attrs) { { } }
  34. it do
  35. is_expected.to be false
  36. end
  37. end
  38. end
  39. describe '#subscribe_address_for' do
  40. before do
  41. remote_follow.valid?
  42. end
  43. let(:attrs) { { acct: 'gargron@quitter.no' } }
  44. let(:account) { Fabricate(:account, username: 'alice') }
  45. subject { remote_follow.subscribe_address_for(account) }
  46. it 'returns subscribe address' do
  47. is_expected.to eq 'https://quitter.no/main/ostatussub?profile=alice%40cb6e6126.ngrok.io'
  48. end
  49. end
  50. end