1
0
mirror of https://github.com/funamitech/mastodon synced 2024-12-24 19:48:28 +09:00
YuruToot/spec/models/remote_follow_spec.rb

68 lines
1.5 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe RemoteFollow do
2017-11-15 04:41:17 +09: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) }
describe '.initialize' do
2017-11-15 04:41:17 +09:00
subject { remote_follow.acct }
2023-05-04 12:49:08 +09:00
context 'when attrs with acct' do
2017-11-15 04:41:17 +09:00
let(:attrs) { { acct: 'gargron@quitter.no' } }
2017-11-15 04:41:17 +09:00
it 'returns acct' do
expect(subject).to eq 'gargron@quitter.no'
end
end
2023-05-04 12:49:08 +09:00
context 'when attrs without acct' do
2017-11-15 04:41:17 +09:00
let(:attrs) { {} }
2017-11-15 04:41:17 +09:00
it do
expect(subject).to be_nil
end
end
end
describe '#valid?' do
2017-11-15 04:41:17 +09:00
subject { remote_follow.valid? }
2023-05-04 12:49:08 +09:00
context 'when attrs with acct' do
2018-10-04 19:36:53 +09:00
let(:attrs) { { acct: 'gargron@quitter.no' } }
2017-11-17 10:52:30 +09:00
2017-11-15 04:41:17 +09:00
it do
expect(subject).to be true
end
end
2023-05-04 12:49:08 +09:00
context 'when attrs without acct' do
2018-10-04 19:36:53 +09:00
let(:attrs) { {} }
2017-11-15 04:41:17 +09:00
it do
expect(subject).to be false
end
end
end
describe '#subscribe_address_for' do
subject { remote_follow.subscribe_address_for(account) }
before do
2017-11-15 04:41:17 +09:00
remote_follow.valid?
end
2017-11-15 04:41:17 +09:00
let(:attrs) { { acct: 'gargron@quitter.no' } }
let(:account) { Fabricate(:account, username: 'alice') }
it 'returns subscribe address' do
expect(subject).to eq 'https://quitter.no/main/ostatussub?profile=https%3A%2F%2Fcb6e6126.ngrok.io%2Fusers%2Falice'
end
end
end