remote_follow_spec.rb 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 'when attrs with acct' do
  12. let(:attrs) { { acct: 'gargron@quitter.no' } }
  13. it 'returns acct' do
  14. expect(subject).to eq 'gargron@quitter.no'
  15. end
  16. end
  17. context 'when attrs without acct' do
  18. let(:attrs) { {} }
  19. it do
  20. expect(subject).to be_nil
  21. end
  22. end
  23. end
  24. describe '#valid?' do
  25. subject { remote_follow.valid? }
  26. context 'when attrs with acct' do
  27. let(:attrs) { { acct: 'gargron@quitter.no' } }
  28. it do
  29. expect(subject).to be true
  30. end
  31. end
  32. context 'when attrs without acct' do
  33. let(:attrs) { {} }
  34. it do
  35. expect(subject).to be false
  36. end
  37. end
  38. end
  39. describe '#subscribe_address_for' do
  40. subject { remote_follow.subscribe_address_for(account) }
  41. before do
  42. remote_follow.valid?
  43. end
  44. let(:attrs) { { acct: 'gargron@quitter.no' } }
  45. let(:account) { Fabricate(:account, username: 'alice') }
  46. it 'returns subscribe address' do
  47. expect(subject).to eq 'https://quitter.no/main/ostatussub?profile=https%3A%2F%2Fcb6e6126.ngrok.io%2Fusers%2Falice'
  48. end
  49. end
  50. end