Merge commit 'c357a7f8d697ede4df4be74456b0497118c9d049' into glitch-soc/merge-upstream

This commit is contained in:
Claire committed 2025-06-30 17:52:22 +02:00
commit 2eec4da8fc
154 files changed
+1168 -826

No files matched your search

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe AccountSuggestions::FaspSource do
describe '#get', feature: :fasp do
subject { described_class.new }
let(:bob) { Fabricate(:account) }
let(:alice) { Fabricate(:account, domain: 'fedi.example.com') }
let(:eve) { Fabricate(:account, domain: 'fedi.example.com') }
before do
[alice, eve].each do |recommended_account|
Fasp::FollowRecommendation.create!(requesting_account: bob, recommended_account:)
end
end
it 'returns recommendations obtained by FASP' do
expect(subject.get(bob)).to contain_exactly([alice.id, :fasp], [eve.id, :fasp])
end
end
end
+81
View File
@@ -3,6 +3,87 @@
require 'rails_helper'
RSpec.describe TermsOfService do
describe 'Validations' do
subject { Fabricate.build :terms_of_service }
it { is_expected.to validate_presence_of(:text) }
it { is_expected.to validate_uniqueness_of(:effective_date) }
it { is_expected.to allow_values(2.days.from_now).for(:effective_date) }
it { is_expected.to_not allow_values(2.days.ago).for(:effective_date) }
context 'with an existing published effective TOS' do
before do
travel_to 5.days.ago do
Fabricate :terms_of_service, published_at: 2.days.ago, effective_date: 1.day.from_now
end
end
it { is_expected.to allow_values(1.day.ago).for(:effective_date) }
end
context 'when published' do
subject { Fabricate.build :terms_of_service, published_at: Time.zone.today }
it { is_expected.to validate_presence_of(:changelog) }
it { is_expected.to validate_presence_of(:effective_date) }
end
end
describe 'Scopes' do
describe '.published' do
let!(:unpublished) { Fabricate :terms_of_service, published_at: nil }
let!(:published_older_effective) { travel_to(3.days.ago) { Fabricate :terms_of_service, published_at: 5.days.ago, effective_date: Time.zone.today } }
let!(:published_newer_effective) { travel_to(2.days.ago) { Fabricate :terms_of_service, published_at: 5.days.ago, effective_date: Time.zone.today } }
it 'returns published records in correct order' do
expect(described_class.published)
.to eq([published_newer_effective, published_older_effective])
.and not_include(unpublished)
end
end
describe '.live' do
let!(:not_effective) { Fabricate :terms_of_service }
let!(:effective_past) { travel_to(3.days.ago) { Fabricate :terms_of_service, effective_date: Time.zone.today } }
let!(:effective_future) { Fabricate :terms_of_service, effective_date: 3.days.from_now }
before { not_effective.update_attribute(:effective_date, nil) }
it 'returns records without effective or with past effective' do
expect(described_class.live)
.to include(not_effective)
.and include(effective_past)
.and not_include(effective_future)
end
end
describe '.upcoming' do
let!(:unpublished) { Fabricate :terms_of_service, published_at: nil }
let!(:effective_past) { travel_to(3.days.ago) { Fabricate :terms_of_service, effective_date: Time.zone.today } }
let!(:effective_future_near) { Fabricate :terms_of_service, effective_date: 3.days.from_now }
let!(:effective_future_far) { Fabricate :terms_of_service, effective_date: 5.days.from_now }
it 'returns published records with future effective date in order of soonest first' do
expect(described_class.upcoming)
.to eq([effective_future_near, effective_future_far])
.and not_include(unpublished)
.and not_include(effective_past)
end
end
describe '.draft' do
let!(:published) { Fabricate :terms_of_service, published_at: 2.days.ago }
let!(:unpublished) { Fabricate :terms_of_service, published_at: nil }
it 'returns not published records' do
expect(described_class.draft)
.to include(unpublished)
.and not_include(published)
end
end
end
describe '#scope_for_notification' do
subject { terms_of_service.scope_for_notification }