Merge remote-tracking branch 'parent/main' into upstream-20240124
This commit is contained in:
commit
54f5113b46
106 changed files with 1396 additions and 1071 deletions
|
@ -1046,6 +1046,31 @@ RSpec.describe Account do
|
|||
end
|
||||
|
||||
describe 'scopes' do
|
||||
describe 'matches_uri_prefix' do
|
||||
let!(:alice) { Fabricate :account, domain: 'host.example', uri: 'https://host.example/user/a' }
|
||||
let!(:bob) { Fabricate :account, domain: 'top-level.example', uri: 'https://top-level.example' }
|
||||
|
||||
it 'returns accounts which start with the value' do
|
||||
results = described_class.matches_uri_prefix('https://host.example')
|
||||
|
||||
expect(results.size)
|
||||
.to eq(1)
|
||||
expect(results)
|
||||
.to include(alice)
|
||||
.and not_include(bob)
|
||||
end
|
||||
|
||||
it 'returns accounts which equal the value' do
|
||||
results = described_class.matches_uri_prefix('https://top-level.example')
|
||||
|
||||
expect(results.size)
|
||||
.to eq(1)
|
||||
expect(results)
|
||||
.to include(bob)
|
||||
.and not_include(alice)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'auditable' do
|
||||
let!(:alice) { Fabricate :account }
|
||||
let!(:bob) { Fabricate :account }
|
||||
|
|
|
@ -100,6 +100,38 @@ RSpec.describe Tag do
|
|||
end
|
||||
end
|
||||
|
||||
describe '.recently_used' do
|
||||
let(:account) { Fabricate(:account) }
|
||||
let(:other_person_status) { Fabricate(:status) }
|
||||
let(:out_of_range) { Fabricate(:status, account: account) }
|
||||
let(:older_in_range) { Fabricate(:status, account: account) }
|
||||
let(:newer_in_range) { Fabricate(:status, account: account) }
|
||||
let(:unused_tag) { Fabricate(:tag) }
|
||||
let(:used_tag_one) { Fabricate(:tag) }
|
||||
let(:used_tag_two) { Fabricate(:tag) }
|
||||
let(:used_tag_on_out_of_range) { Fabricate(:tag) }
|
||||
|
||||
before do
|
||||
stub_const 'Tag::RECENT_STATUS_LIMIT', 2
|
||||
|
||||
other_person_status.tags << used_tag_one
|
||||
|
||||
out_of_range.tags << used_tag_on_out_of_range
|
||||
|
||||
older_in_range.tags << used_tag_one
|
||||
older_in_range.tags << used_tag_two
|
||||
|
||||
newer_in_range.tags << used_tag_one
|
||||
end
|
||||
|
||||
it 'returns tags used by account within last X statuses ordered most used first' do
|
||||
results = described_class.recently_used(account)
|
||||
|
||||
expect(results)
|
||||
.to eq([used_tag_one, used_tag_two])
|
||||
end
|
||||
end
|
||||
|
||||
describe '.find_normalized' do
|
||||
it 'returns tag for a multibyte case-insensitive name' do
|
||||
upcase_string = 'abcABCabcABCやゆよ'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue