1
0
Fork 0
forked from gitea/nas

Merge remote-tracking branch 'parent/main' into upstream-20240731

This commit is contained in:
KMY 2024-07-31 13:00:13 +09:00
commit 8b09a57a91
320 changed files with 3132 additions and 1643 deletions

View file

@ -934,6 +934,14 @@ RSpec.describe Account do
it 'does not match URL query string' do
expect(subject.match('https://example.com/?x=@alice')).to be_nil
end
it 'matches usernames immediately following the letter ß' do
expect(subject.match('Hello toß @alice from me')[1]).to eq 'alice'
end
it 'matches usernames containing uppercase characters' do
expect(subject.match('Hello to @aLice@Example.com from me')[1]).to eq 'aLice@Example.com'
end
end
describe 'validations' do

View file

@ -0,0 +1,36 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::TagFilter do
describe 'with invalid params' do
it 'raises with key error' do
filter = described_class.new(wrong: true)
expect { filter.results }.to raise_error(/wrong/)
end
it 'raises with status scope error' do
filter = described_class.new(status: 'unknown')
expect { filter.results }.to raise_error(/Unknown status: unknown/)
end
it 'raises with order value error' do
filter = described_class.new(order: 'unknown')
expect { filter.results }.to raise_error(/Unknown order: unknown/)
end
end
describe '#results' do
let(:listable_tag) { Fabricate(:tag, name: 'test1', listable: true) }
let(:not_listable_tag) { Fabricate(:tag, name: 'test2', listable: false) }
it 'returns tags filtered by name' do
filter = described_class.new(name: 'test')
expect(filter.results).to eq([listable_tag, not_listable_tag])
end
end
end

View file

@ -95,6 +95,14 @@ RSpec.describe Tag do
it 'does not match purely-numeric hashtags' do
expect(subject.match('hello #0123456')).to be_nil
end
it 'matches hashtags immediately following the letter ß' do
expect(subject.match('Hello toß #ruby').to_s).to eq '#ruby'
end
it 'matches hashtags containing uppercase characters' do
expect(subject.match('Hello #rubyOnRails').to_s).to eq '#rubyOnRails'
end
end
describe '#to_param' do
@ -104,6 +112,18 @@ RSpec.describe Tag do
end
end
describe '#formatted_name' do
it 'returns name with a proceeding hash symbol' do
tag = Fabricate(:tag, name: 'foo')
expect(tag.formatted_name).to eq '#foo'
end
it 'returns display_name with a proceeding hash symbol, if display name present' do
tag = Fabricate(:tag, name: 'foobar', display_name: 'FooBar')
expect(tag.formatted_name).to eq '#FooBar'
end
end
describe '.recently_used' do
let(:account) { Fabricate(:account) }
let(:other_person_status) { Fabricate(:status) }
@ -232,5 +252,23 @@ RSpec.describe Tag do
expect(results).to eq [tag, similar_tag]
end
it 'finds only listable tags' do
tag = Fabricate(:tag, name: 'match')
_miss_tag = Fabricate(:tag, name: 'matchunlisted', listable: false)
results = described_class.search_for('match')
expect(results).to eq [tag]
end
it 'finds non-listable tags as well via option' do
tag = Fabricate(:tag, name: 'match')
unlisted_tag = Fabricate(:tag, name: 'matchunlisted', listable: false)
results = described_class.search_for('match', 5, 0, exclude_unlistable: false)
expect(results).to eq [tag, unlisted_tag]
end
end
end