2023-02-22 09:55:31 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 16:58:38 +09:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-03-13 17:39:26 +09:00
|
|
|
RSpec.describe BootstrapTimelineService do
|
2023-06-06 20:58:33 +09:00
|
|
|
subject { described_class.new }
|
2021-07-08 04:12:43 +09:00
|
|
|
|
|
|
|
context 'when the new user has registered from an invite' do
|
2023-06-22 21:55:22 +09:00
|
|
|
let(:service) { instance_double(FollowService) }
|
2021-07-08 04:12:43 +09:00
|
|
|
let(:autofollow) { false }
|
|
|
|
let(:inviter) { Fabricate(:user, confirmed_at: 2.days.ago) }
|
|
|
|
let(:invite) { Fabricate(:invite, user: inviter, max_uses: nil, expires_at: 1.hour.from_now, autofollow: autofollow) }
|
|
|
|
let(:new_user) { Fabricate(:user, invite_code: invite.code) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(FollowService).to receive(:new).and_return(service)
|
|
|
|
allow(service).to receive(:call)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the invite has auto-follow enabled' do
|
|
|
|
let(:autofollow) { true }
|
|
|
|
|
|
|
|
it 'calls FollowService to follow the inviter' do
|
|
|
|
subject.call(new_user.account)
|
|
|
|
expect(service).to have_received(:call).with(new_user.account, inviter.account)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the invite does not have auto-follow enable' do
|
|
|
|
let(:autofollow) { false }
|
|
|
|
|
|
|
|
it 'calls FollowService to follow the inviter' do
|
|
|
|
subject.call(new_user.account)
|
|
|
|
expect(service).to_not have_received(:call)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-09-10 16:58:38 +09:00
|
|
|
end
|