diff options
author | ThibG <thib@sitedethib.com> | 2020-04-17 22:36:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-17 22:36:48 +0200 |
commit | 62e65dca11e1c39630db2958c514c45407dcdfa7 (patch) | |
tree | 92b5f9a2f93a2355dd94bac7e63e8fd9c552dafb /spec | |
parent | 5fdd5eef5a6b05b072a57e065954fdcb0b4a8898 (diff) | |
parent | 81ef26b67d01aaa693edbdcf7a8f2a6cdfd56920 (diff) |
Merge pull request #1318 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'spec')
-rw-r--r-- | spec/fabricators/unavailable_domain_fabricator.rb | 3 | ||||
-rw-r--r-- | spec/lib/delivery_failure_tracker_spec.rb | 30 | ||||
-rw-r--r-- | spec/models/unavailable_domain_spec.rb | 4 |
3 files changed, 18 insertions, 19 deletions
diff --git a/spec/fabricators/unavailable_domain_fabricator.rb b/spec/fabricators/unavailable_domain_fabricator.rb new file mode 100644 index 000000000..f661b87c4 --- /dev/null +++ b/spec/fabricators/unavailable_domain_fabricator.rb @@ -0,0 +1,3 @@ +Fabricator(:unavailable_domain) do + domain { Faker::Internet.domain } +end diff --git a/spec/lib/delivery_failure_tracker_spec.rb b/spec/lib/delivery_failure_tracker_spec.rb index 39c8c7aaf..52a1a92f0 100644 --- a/spec/lib/delivery_failure_tracker_spec.rb +++ b/spec/lib/delivery_failure_tracker_spec.rb @@ -22,11 +22,11 @@ describe DeliveryFailureTracker do describe '#track_failure!' do it 'marks URL as unavailable after 7 days of being called' do - 6.times { |i| Redis.current.sadd('exhausted_deliveries:http://example.com/inbox', i) } + 6.times { |i| Redis.current.sadd('exhausted_deliveries:example.com', i) } subject.track_failure! expect(subject.days).to eq 7 - expect(described_class.unavailable?('http://example.com/inbox')).to be true + expect(described_class.available?('http://example.com/inbox')).to be false end it 'repeated calls on the same day do not count' do @@ -37,35 +37,27 @@ describe DeliveryFailureTracker do end end - describe '.filter' do + describe '.without_unavailable' do before do - Redis.current.sadd('unavailable_inboxes', 'http://example.com/unavailable/inbox') + Fabricate(:unavailable_domain, domain: 'foo.bar') end it 'removes URLs that are unavailable' do - result = described_class.filter(['http://example.com/good/inbox', 'http://example.com/unavailable/inbox']) + results = described_class.without_unavailable(['http://example.com/good/inbox', 'http://foo.bar/unavailable/inbox']) - expect(result).to include('http://example.com/good/inbox') - expect(result).to_not include('http://example.com/unavailable/inbox') + expect(results).to include('http://example.com/good/inbox') + expect(results).to_not include('http://foo.bar/unavailable/inbox') end end - describe '.track_inverse_success!' do - let(:from_account) { Fabricate(:account, inbox_url: 'http://example.com/inbox', shared_inbox_url: 'http://example.com/shared/inbox') } - + describe '.reset!' do before do - Redis.current.sadd('unavailable_inboxes', 'http://example.com/inbox') - Redis.current.sadd('unavailable_inboxes', 'http://example.com/shared/inbox') - - described_class.track_inverse_success!(from_account) + 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://example.com/inbox')).to be true - end - - it 'marks shared inbox URL as available again' do - expect(described_class.available?('http://example.com/shared/inbox')).to be true + expect(described_class.available?('http://foo.bar/inbox')).to be true end end end diff --git a/spec/models/unavailable_domain_spec.rb b/spec/models/unavailable_domain_spec.rb new file mode 100644 index 000000000..3f2621034 --- /dev/null +++ b/spec/models/unavailable_domain_spec.rb @@ -0,0 +1,4 @@ +require 'rails_helper' + +RSpec.describe UnavailableDomain, type: :model do +end |