1
0
Fork 0
forked from gitea/nas

Merge commit '13ab4b54e2' into upstream-20241204-15

This commit is contained in:
KMY 2024-12-04 08:37:37 +09:00
commit a6a237bc8e
228 changed files with 2678 additions and 1266 deletions

View file

@ -126,16 +126,54 @@ RSpec.describe FeaturedTag do
end
describe '#decrement' do
it 'decreases the count and updates the last_status_at timestamp' do
tag = Fabricate :tag, name: 'test'
status = Fabricate :status, visibility: :public, created_at: 10.days.ago
status.tags << tag
let(:tag) { Fabricate(:tag, name: 'test') }
let(:account) { Fabricate(:account) }
let(:featured_tag) { Fabricate(:featured_tag, name: 'test', account: account) }
featured_tag = Fabricate :featured_tag, name: 'test', account: status.account
context 'when removing the last status using the tag' do
let(:status) { Fabricate(:status, visibility: :public, account: account, created_at: 10.days.ago) }
expect { featured_tag.decrement(status.id) }
.to change(featured_tag, :statuses_count).from(1).to(0)
.and change(featured_tag, :last_status_at).to(nil)
before do
status.tags << tag
end
it 'decreases the count and updates the last_status_at timestamp' do
expect { featured_tag.decrement(status) }
.to change(featured_tag, :statuses_count).from(1).to(0)
.and change(featured_tag, :last_status_at).to(nil)
end
end
context 'when removing a previous status using the tag' do
let(:previous_status) { Fabricate(:status, visibility: :public, account: account, created_at: 1.month.ago) }
let(:status) { Fabricate(:status, visibility: :public, account: account, created_at: 10.days.ago) }
before do
previous_status.tags << tag
status.tags << tag
end
it 'decreases the count and updates the last_status_at timestamp' do
expect { featured_tag.decrement(previous_status) }
.to change(featured_tag, :statuses_count).from(2).to(1)
.and not_change(featured_tag, :last_status_at)
end
end
context 'when removing the most recent use of the tag' do
let(:previous_status) { Fabricate(:status, visibility: :public, account: account, created_at: 1.month.ago) }
let(:status) { Fabricate(:status, visibility: :public, account: account, created_at: 10.days.ago) }
before do
previous_status.tags << tag
status.tags << tag
end
it 'decreases the count and updates the last_status_at timestamp' do
expect { featured_tag.decrement(status) }
.to change(featured_tag, :statuses_count).from(2).to(1)
.and change(featured_tag, :last_status_at)
end
end
end
end

View file

@ -11,7 +11,11 @@ RSpec.describe List do
context 'when account has hit max list limit' do
let(:account) { Fabricate :account }
before { stub_const 'List::PER_ACCOUNT_LIMIT', 0 }
before do
stub_const 'List::PER_ACCOUNT_LIMIT', 1
Fabricate(:list, account: account)
end
context 'when creating a new list' do
it { is_expected.to_not allow_value(account).for(:account).against(:base).with_message(I18n.t('lists.errors.limit')) }