mastodon/spec/models/remote_follow_spec.rb

68 lines
1.4 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe RemoteFollow do
2017-11-14 11:41:17 -08: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-14 11:41:17 -08:00
subject { remote_follow.acct }
2017-11-14 11:41:17 -08:00
context 'attrs with acct' do
let(:attrs) { { acct: 'gargron@quitter.no' } }
2017-11-14 11:41:17 -08:00
it 'returns acct' do
is_expected.to eq 'gargron@quitter.no'
end
end
2017-11-14 11:41:17 -08:00
context 'attrs without acct' do
let(:attrs) { {} }
2017-11-14 11:41:17 -08:00
it do
is_expected.to be_nil
end
end
end
describe '#valid?' do
2017-11-14 11:41:17 -08:00
subject { remote_follow.valid? }
2017-11-14 11:41:17 -08:00
context 'attrs with acct' do
2018-10-04 03:36:53 -07:00
let(:attrs) { { acct: 'gargron@quitter.no' } }
2017-11-16 17:52:30 -08:00
2017-11-14 11:41:17 -08:00
it do
is_expected.to be true
end
end
2017-11-14 11:41:17 -08:00
context 'attrs without acct' do
2018-10-04 03:36:53 -07:00
let(:attrs) { {} }
2017-11-14 11:41:17 -08:00
it do
is_expected.to be false
end
end
end
describe '#subscribe_address_for' do
before do
2017-11-14 11:41:17 -08:00
remote_follow.valid?
end
2017-11-14 11:41:17 -08:00
let(:attrs) { { acct: 'gargron@quitter.no' } }
let(:account) { Fabricate(:account, username: 'alice') }
subject { remote_follow.subscribe_address_for(account) }
2017-11-14 11:41:17 -08:00
it 'returns subscribe address' do
is_expected.to eq 'https://quitter.no/main/ostatussub?profile=alice%40cb6e6126.ngrok.io'
end
end
end