Merge tag 'v3.1.4' into hometown-dev
This commit is contained in:
37
spec/models/relationship_filter_spec.rb
Normal file
37
spec/models/relationship_filter_spec.rb
Normal file
@ -0,0 +1,37 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe RelationshipFilter do
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
describe '#results' do
|
||||
context 'when default params are used' do
|
||||
let(:subject) do
|
||||
RelationshipFilter.new(account, 'order' => 'active').results
|
||||
end
|
||||
|
||||
before do
|
||||
add_following_account_with(last_status_at: 7.days.ago)
|
||||
add_following_account_with(last_status_at: 1.day.ago)
|
||||
add_following_account_with(last_status_at: 3.days.ago)
|
||||
end
|
||||
|
||||
it 'returns followings ordered by last activity' do
|
||||
expected_result = account.following.eager_load(:account_stat).reorder(nil).by_recent_status
|
||||
|
||||
expect(subject).to eq expected_result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def add_following_account_with(last_status_at:)
|
||||
following_account = Fabricate(:account)
|
||||
Fabricate(:account_stat, account: following_account,
|
||||
last_status_at: last_status_at,
|
||||
statuses_count: 1,
|
||||
following_count: 0,
|
||||
followers_count: 0)
|
||||
Fabricate(:follow, account: account, target_account: following_account).account
|
||||
end
|
||||
end
|
@ -82,39 +82,6 @@ RSpec.describe Status, type: :model do
|
||||
end
|
||||
end
|
||||
|
||||
describe '#title' do
|
||||
# rubocop:disable Style/InterpolationCheck
|
||||
|
||||
let(:account) { subject.account }
|
||||
|
||||
context 'if destroyed?' do
|
||||
it 'returns "#{account.acct} deleted status"' do
|
||||
subject.destroy!
|
||||
expect(subject.title).to eq "#{account.acct} deleted status"
|
||||
end
|
||||
end
|
||||
|
||||
context 'unless destroyed?' do
|
||||
context 'if reblog?' do
|
||||
it 'returns "#{account.acct} shared #{reblog.account.acct}\'s: #{preview}"' do
|
||||
reblog = subject.reblog = other
|
||||
preview = subject.text.slice(0, 10).split("\n")[0]
|
||||
expect(subject.title).to(
|
||||
eq "#{account.acct} shared #{reblog.account.acct}'s: #{preview}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'unless reblog?' do
|
||||
it 'returns "#{account.acct}: #{preview}"' do
|
||||
subject.reblog = nil
|
||||
preview = subject.text.slice(0, 20).split("\n")[0]
|
||||
expect(subject.title).to eq "#{account.acct}: #{preview}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#hidden?' do
|
||||
context 'if private_visibility?' do
|
||||
it 'returns true' do
|
||||
@ -407,6 +374,33 @@ RSpec.describe Status, type: :model do
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a remote_only option set' do
|
||||
let!(:local_account) { Fabricate(:account, domain: nil) }
|
||||
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
|
||||
let!(:local_status) { Fabricate(:status, account: local_account) }
|
||||
let!(:remote_status) { Fabricate(:status, account: remote_account) }
|
||||
|
||||
subject { Status.as_public_timeline(viewer, :remote) }
|
||||
|
||||
context 'without a viewer' do
|
||||
let(:viewer) { nil }
|
||||
|
||||
it 'does not include local instances statuses' do
|
||||
expect(subject).not_to include(local_status)
|
||||
expect(subject).to include(remote_status)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a viewer' do
|
||||
let(:viewer) { Fabricate(:account, username: 'viewer') }
|
||||
|
||||
it 'does not include local instances statuses' do
|
||||
expect(subject).not_to include(local_status)
|
||||
expect(subject).to include(remote_status)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with an account passed in' do
|
||||
before do
|
||||
@account = Fabricate(:account)
|
||||
|
4
spec/models/unavailable_domain_spec.rb
Normal file
4
spec/models/unavailable_domain_spec.rb
Normal file
@ -0,0 +1,4 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe UnavailableDomain, type: :model do
|
||||
end
|
Reference in New Issue
Block a user