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

This commit is contained in:
Claire committed 2026-03-09 12:41:12 +01:00
commit 4bcd0caa79
70 files changed
+1060 -109

No files matched your search

+9
View File
@@ -3,6 +3,15 @@
require 'rails_helper'
RSpec.describe AccountsIndex do
context 'when elasticsearch is enabled', :search do
describe 'indexing records' do
it 'indexes records from scope' do
expect { Fabricate :account }
.to change(described_class, :count).by(1)
end
end
end
describe 'Searching the index' do
before do
mock_elasticsearch_response(described_class, raw_response)
+9
View File
@@ -3,6 +3,15 @@
require 'rails_helper'
RSpec.describe PublicStatusesIndex do
context 'when elasticsearch is enabled', :search do
describe 'indexing records' do
it 'indexes records from scope' do
expect { Fabricate :status, visibility: :public }
.to change(described_class, :count).by(1)
end
end
end
describe 'Searching the index' do
before do
mock_elasticsearch_response(described_class, raw_response)
+9
View File
@@ -3,6 +3,15 @@
require 'rails_helper'
RSpec.describe StatusesIndex do
context 'when elasticsearch is enabled', :search do
describe 'indexing records' do
it 'indexes records from scope' do
expect { Fabricate :status }
.to change(described_class, :count).by(1)
end
end
end
describe 'Searching the index' do
before do
mock_elasticsearch_response(described_class, raw_response)
+9
View File
@@ -3,6 +3,15 @@
require 'rails_helper'
RSpec.describe TagsIndex do
context 'when elasticsearch is enabled', :search do
describe 'indexing records' do
it 'indexes records from scope' do
expect { Fabricate :tag, listable: true }
.to change(described_class, :count).by(1)
end
end
end
describe 'Searching the index' do
before do
mock_elasticsearch_response(described_class, raw_response)
@@ -101,7 +101,6 @@ RSpec.describe Mastodon::CLI::EmailDomainBlocks do
context 'when no blocks exist' do
let(:domain) { 'host.example' }
let(:arguments) { [domain] }
let(:options) { { allow_with_approval: false } }
it 'adds a new block' do
expect { subject }
@@ -113,7 +112,7 @@ RSpec.describe Mastodon::CLI::EmailDomainBlocks do
context 'with --with-dns-records true' do
let(:domain) { 'host.example' }
let(:arguments) { [domain] }
let(:options) { { allow_with_approval: false, with_dns_records: true } }
let(:options) { { with_dns_records: true } }
before do
configure_mx(domain: domain, exchange: 'other.host')
+18
View File
@@ -108,6 +108,24 @@ RSpec.describe TermsOfService do
end
end
describe '#usable_effective_date' do
subject { terms_of_service.usable_effective_date }
let(:terms_of_service) { Fabricate.build(:terms_of_service, effective_date:) }
context 'when effective_date value is set' do
let(:effective_date) { 5.days.ago }
it { is_expected.to eq(effective_date.to_date) }
end
context 'when effective_date value is not set' do
let(:effective_date) { nil }
it { is_expected.to eq(Time.zone.today) }
end
end
describe '::current' do
context 'when no terms exist' do
it 'returns nil' do
+2 -2
View File
@@ -252,13 +252,13 @@ RSpec.describe 'ActivityPub Replies' do
def inlined_replies
response
.parsed_body[:first][:items]
.select { |x| x.is_a?(Hash) }
.grep(Hash)
end
def remote_replies
response
.parsed_body[:first][:items]
.reject { |x| x.is_a?(Hash) }
.grep_v(Hash)
end
def parsed_uri_query_values(uri)
@@ -86,4 +86,16 @@ RSpec.describe AccountSearchService do
expect(results).to eq []
end
end
context 'when elasticsearch is enabled', :search do
it 'returns matching accounts' do
account = Fabricate(:account, username: 'matchingusername')
AccountsIndex.import!
results = subject.call('match', nil, limit: 5)
expect(results).to eq [account]
end
end
end
@@ -0,0 +1,22 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe StatusesSearchService do
describe '#call' do
let!(:status) { Fabricate(:status, text: 'status number one') }
let(:results) { subject.call('one', status.account, limit: 5) }
before { Fabricate(:status, text: 'status number two') }
context 'when elasticsearch is enabled', :search do
it 'runs a search for statuses' do
expect(results)
.to have_attributes(
size: 1,
first: eq(status)
)
end
end
end
end
+18 -7
View File
@@ -5,17 +5,28 @@ require 'rails_helper'
RSpec.describe TagSearchService do
describe '#call' do
let!(:one) { Fabricate(:tag, name: 'one') }
let(:results) { subject.call('#one', limit: 5) }
before { Fabricate(:tag, name: 'two') }
it 'runs a search for tags' do
results = subject.call('#one', limit: 5)
context 'with postgres search' do
it 'runs a search for tags' do
expect(results)
.to have_attributes(
size: 1,
first: eq(one)
)
end
end
expect(results)
.to have_attributes(
size: 1,
first: eq(one)
)
context 'when elasticsearch is enabled', :search do
it 'runs a search for tags' do
expect(results)
.to have_attributes(
size: 1,
first: eq(one)
)
end
end
end
end