mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-25 19:01:37 +01:00
0b66cfbc8d
Some checks failed
Bundler Audit / security (push) Has been cancelled
Check i18n / check-i18n (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (ruby) (push) Has been cancelled
Crowdin / Upload translations / upload-translations (push) Has been cancelled
Check formatting / lint (push) Has been cancelled
CSS Linting / lint (push) Has been cancelled
Haml Linting / lint (push) Has been cancelled
JavaScript Linting / lint (push) Has been cancelled
Ruby Linting / lint (push) Has been cancelled
JavaScript Testing / test (push) Has been cancelled
Historical data migration test / test (14-alpine) (push) Has been cancelled
Historical data migration test / test (15-alpine) (push) Has been cancelled
Ruby Testing / build (production) (push) Has been cancelled
Ruby Testing / build (test) (push) Has been cancelled
Ruby Testing / test (.ruby-version) (push) Has been cancelled
Ruby Testing / test (3.1) (push) Has been cancelled
Ruby Testing / test (3.2) (push) Has been cancelled
Ruby Testing / Libvips tests (.ruby-version) (push) Has been cancelled
Ruby Testing / Libvips tests (3.1) (push) Has been cancelled
Ruby Testing / Libvips tests (3.2) (push) Has been cancelled
Ruby Testing / End to End testing (.ruby-version) (push) Has been cancelled
Ruby Testing / End to End testing (3.1) (push) Has been cancelled
Ruby Testing / End to End testing (3.2) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (3.1, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Has been cancelled
63 lines
1.7 KiB
Ruby
63 lines
1.7 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe DeliveryFailureTracker do
|
|
subject { described_class.new('http://example.com/inbox') }
|
|
|
|
describe '#track_success!' do
|
|
before do
|
|
subject.track_failure!
|
|
subject.track_success!
|
|
end
|
|
|
|
it 'marks URL as available again' do
|
|
expect(described_class.available?('http://example.com/inbox')).to be true
|
|
end
|
|
|
|
it 'resets days to 0' do
|
|
expect(subject.days).to be_zero
|
|
end
|
|
end
|
|
|
|
describe '#track_failure!' do
|
|
it 'marks URL as unavailable after 7 days of being called' do
|
|
6.times { |i| redis.sadd?('exhausted_deliveries:example.com', i) }
|
|
subject.track_failure!
|
|
|
|
expect(subject.days).to eq 7
|
|
expect(described_class.available?('http://example.com/inbox')).to be false
|
|
end
|
|
|
|
it 'repeated calls on the same day do not count' do
|
|
subject.track_failure!
|
|
subject.track_failure!
|
|
|
|
expect(subject.days).to eq 1
|
|
end
|
|
end
|
|
|
|
describe '.without_unavailable' do
|
|
before do
|
|
Fabricate(:unavailable_domain, domain: 'foo.bar')
|
|
end
|
|
|
|
it 'removes URLs that are unavailable' do
|
|
results = described_class.without_unavailable(['http://example.com/good/inbox', 'http://foo.bar/unavailable/inbox'])
|
|
|
|
expect(results).to include('http://example.com/good/inbox')
|
|
expect(results).to_not include('http://foo.bar/unavailable/inbox')
|
|
end
|
|
end
|
|
|
|
describe '.reset!' do
|
|
before do
|
|
Fabricate(:unavailable_domain, domain: 'foo.bar')
|
|
described_class.reset!('https://foo.bar/inbox')
|
|
end
|
|
|
|
it 'marks inbox URL as available again' do
|
|
expect(described_class.available?('http://foo.bar/inbox')).to be true
|
|
end
|
|
end
|
|
end
|