2017-11-11 02:56:02 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe RemoteFollow do
|
2017-11-15 06:41:17 +11:00
|
|
|
before do
|
|
|
|
stub_request(:get, 'https://quitter.no/.well-known/webfinger?resource=acct:gargron@quitter.no').to_return(request_fixture('webfinger.txt'))
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:attrs) { nil }
|
|
|
|
let(:remote_follow) { described_class.new(attrs) }
|
|
|
|
|
2017-11-11 02:56:02 +11:00
|
|
|
describe '.initialize' do
|
2017-11-15 06:41:17 +11:00
|
|
|
subject { remote_follow.acct }
|
2017-11-11 02:56:02 +11:00
|
|
|
|
2023-05-04 13:49:08 +10:00
|
|
|
context 'when attrs with acct' do
|
2017-11-15 06:41:17 +11:00
|
|
|
let(:attrs) { { acct: 'gargron@quitter.no' } }
|
2017-11-11 02:56:02 +11:00
|
|
|
|
2017-11-15 06:41:17 +11:00
|
|
|
it 'returns acct' do
|
2023-02-20 15:00:48 +11:00
|
|
|
expect(subject).to eq 'gargron@quitter.no'
|
2017-11-11 02:56:02 +11:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-05-04 13:49:08 +10:00
|
|
|
context 'when attrs without acct' do
|
2017-11-15 06:41:17 +11:00
|
|
|
let(:attrs) { {} }
|
2017-11-11 02:56:02 +11:00
|
|
|
|
2017-11-15 06:41:17 +11:00
|
|
|
it do
|
2023-02-20 15:00:48 +11:00
|
|
|
expect(subject).to be_nil
|
2017-11-11 02:56:02 +11:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#valid?' do
|
2017-11-15 06:41:17 +11:00
|
|
|
subject { remote_follow.valid? }
|
2017-11-11 02:56:02 +11:00
|
|
|
|
2023-05-04 13:49:08 +10:00
|
|
|
context 'when attrs with acct' do
|
2018-10-04 20:36:53 +10:00
|
|
|
let(:attrs) { { acct: 'gargron@quitter.no' } }
|
2017-11-17 12:52:30 +11:00
|
|
|
|
2017-11-15 06:41:17 +11:00
|
|
|
it do
|
2023-02-20 15:00:48 +11:00
|
|
|
expect(subject).to be true
|
2017-11-11 02:56:02 +11:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-05-04 13:49:08 +10:00
|
|
|
context 'when attrs without acct' do
|
2018-10-04 20:36:53 +10:00
|
|
|
let(:attrs) { {} }
|
2017-11-11 02:56:02 +11:00
|
|
|
|
2017-11-15 06:41:17 +11:00
|
|
|
it do
|
2023-02-20 15:00:48 +11:00
|
|
|
expect(subject).to be false
|
2017-11-11 02:56:02 +11:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#subscribe_address_for' do
|
2023-02-20 15:24:14 +11:00
|
|
|
subject { remote_follow.subscribe_address_for(account) }
|
|
|
|
|
2017-11-11 02:56:02 +11:00
|
|
|
before do
|
2017-11-15 06:41:17 +11:00
|
|
|
remote_follow.valid?
|
2017-11-11 02:56:02 +11:00
|
|
|
end
|
|
|
|
|
2017-11-15 06:41:17 +11:00
|
|
|
let(:attrs) { { acct: 'gargron@quitter.no' } }
|
|
|
|
let(:account) { Fabricate(:account, username: 'alice') }
|
|
|
|
|
|
|
|
it 'returns subscribe address' do
|
2023-02-20 15:00:48 +11:00
|
|
|
expect(subject).to eq 'https://quitter.no/main/ostatussub?profile=https%3A%2F%2Fcb6e6126.ngrok.io%2Fusers%2Falice'
|
2017-11-11 02:56:02 +11:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|