Merge remote-tracking branch 'parent/main' into kb_development
This commit is contained in:
commit
3ccf0d02c6
39 changed files with 828 additions and 728 deletions
|
@ -60,4 +60,30 @@ describe LanguagesHelper do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'sorted_locales' do
|
||||
context 'when sorting with native name' do
|
||||
it 'returns Suomi after Gàidhlig' do
|
||||
expect(described_class.sorted_locale_keys(%w(fi gd))).to eq(%w(gd fi))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when sorting with diacritics' do
|
||||
it 'returns Íslensk before Suomi' do
|
||||
expect(described_class.sorted_locale_keys(%w(fi is))).to eq(%w(is fi))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when sorting with non-Latin' do
|
||||
it 'returns Suomi before Amharic' do
|
||||
expect(described_class.sorted_locale_keys(%w(am fi))).to eq(%w(fi am))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when sorting with local variants' do
|
||||
it 'returns variant in-line' do
|
||||
expect(described_class.sorted_locale_keys(%w(en eo en-GB))).to eq(%w(en en-GB eo))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,6 +28,14 @@ describe CacheBuster do
|
|||
end
|
||||
|
||||
context 'when using default options' do
|
||||
around do |example|
|
||||
# Disables the CacheBuster.new deprecation warning about default arguments.
|
||||
# Remove this `silence` block when default arg support is removed from CacheBuster
|
||||
ActiveSupport::Deprecation.silence do
|
||||
example.run
|
||||
end
|
||||
end
|
||||
|
||||
include_examples 'makes_request'
|
||||
end
|
||||
|
||||
|
|
|
@ -6,32 +6,60 @@ describe RelationshipFilter do
|
|||
let(:account) { Fabricate(:account) }
|
||||
|
||||
describe '#results' do
|
||||
context 'when default params are used' do
|
||||
subject do
|
||||
described_class.new(account, 'order' => 'active').results
|
||||
let(:account_of_7_months) { Fabricate(:account_stat, statuses_count: 1, last_status_at: 7.months.ago).account }
|
||||
let(:account_of_1_day) { Fabricate(:account_stat, statuses_count: 1, last_status_at: 1.day.ago).account }
|
||||
let(:account_of_3_days) { Fabricate(:account_stat, statuses_count: 1, last_status_at: 3.days.ago).account }
|
||||
let(:silent_account) { Fabricate(:account_stat, statuses_count: 0, last_status_at: nil).account }
|
||||
|
||||
before do
|
||||
account.follow!(account_of_7_months)
|
||||
account.follow!(account_of_1_day)
|
||||
account.follow!(account_of_3_days)
|
||||
account.follow!(silent_account)
|
||||
end
|
||||
|
||||
context 'when ordering by last activity' do
|
||||
context 'when not filtering' do
|
||||
subject do
|
||||
described_class.new(account, 'order' => 'active').results
|
||||
end
|
||||
|
||||
it 'returns followings ordered by last activity' do
|
||||
expect(subject).to eq [account_of_1_day, account_of_3_days, account_of_7_months, silent_account]
|
||||
end
|
||||
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)
|
||||
context 'when filtering for dormant accounts' do
|
||||
subject do
|
||||
described_class.new(account, 'order' => 'active', 'activity' => 'dormant').results
|
||||
end
|
||||
|
||||
it 'returns dormant followings ordered by last activity' do
|
||||
expect(subject).to eq [account_of_7_months, silent_account]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ordering by account creation' do
|
||||
context 'when not filtering' do
|
||||
subject do
|
||||
described_class.new(account, 'order' => 'recent').results
|
||||
end
|
||||
|
||||
it 'returns followings ordered by last account creation' do
|
||||
expect(subject).to eq [silent_account, account_of_3_days, account_of_1_day, account_of_7_months]
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns followings ordered by last activity' do
|
||||
expected_result = account.following.eager_load(:account_stat).reorder(nil).by_recent_status
|
||||
context 'when filtering for dormant accounts' do
|
||||
subject do
|
||||
described_class.new(account, 'order' => 'recent', 'activity' => 'dormant').results
|
||||
end
|
||||
|
||||
expect(subject).to eq expected_result
|
||||
it 'returns dormant followings ordered by last activity' do
|
||||
expect(subject).to eq [silent_account, account_of_7_months]
|
||||
end
|
||||
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
|
||||
|
|
|
@ -30,6 +30,7 @@ module TestEndpoints
|
|||
/directory
|
||||
/@alice
|
||||
/@alice/110224538612341312
|
||||
/deck/home
|
||||
).freeze
|
||||
|
||||
# Endpoints that should be cachable when accessed anonymously but have a Vary
|
||||
|
|
|
@ -9,7 +9,7 @@ describe ActivityPub::NoteSerializer do
|
|||
let(:searchability) { :public }
|
||||
let!(:account) { Fabricate(:account) }
|
||||
let!(:other) { Fabricate(:account) }
|
||||
let!(:parent) { Fabricate(:status, account: account, visibility: visibility, searchability: searchability) }
|
||||
let!(:parent) { Fabricate(:status, account: account, visibility: visibility, searchability: searchability, language: 'zh-TW') }
|
||||
let!(:reply_by_account_first) { Fabricate(:status, account: account, thread: parent, visibility: :public) }
|
||||
let!(:reply_by_account_next) { Fabricate(:status, account: account, thread: parent, visibility: :public) }
|
||||
let!(:reply_by_other_first) { Fabricate(:status, account: other, thread: parent, visibility: :public) }
|
||||
|
@ -24,8 +24,15 @@ describe ActivityPub::NoteSerializer do
|
|||
@serialization = ActiveModelSerializers::SerializableResource.new(parent, serializer: described_class, adapter: ActivityPub::Adapter)
|
||||
end
|
||||
|
||||
it 'has a Note type' do
|
||||
expect(subject['type']).to eql('Note')
|
||||
it 'has the expected shape' do
|
||||
expect(subject).to include({
|
||||
'@context' => include('https://www.w3.org/ns/activitystreams'),
|
||||
'type' => 'Note',
|
||||
'attributedTo' => ActivityPub::TagManager.instance.uri_for(account),
|
||||
'contentMap' => include({
|
||||
'zh-TW' => a_kind_of(String),
|
||||
}),
|
||||
})
|
||||
end
|
||||
|
||||
it 'has a replies collection' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue