diff options
author | Starfall <us@starfall.systems> | 2022-04-29 09:20:51 -0500 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2022-04-29 09:20:51 -0500 |
commit | 4eb291e5db6114c8aa564f0c9e7f04d13805b5cc (patch) | |
tree | 1a6affcf635974ccf6d0f650a3bbe2be75c7929e /spec/lib | |
parent | bcaacc42334d75bd361f330989041a9beba101a9 (diff) | |
parent | 252deefe3433d0cedafd973becd0d85b5182eb49 (diff) |
Merge remote-tracking branch 'glitch/main'
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/activitypub/activity/create_spec.rb | 52 | ||||
-rw-r--r-- | spec/lib/activitypub/activity/move_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/delivery_failure_tracker_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/feed_manager_spec.rb | 28 |
4 files changed, 69 insertions, 17 deletions
diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb index 3e9cbba92..738e644c5 100644 --- a/spec/lib/activitypub/activity/create_spec.rb +++ b/spec/lib/activitypub/activity/create_spec.rb @@ -29,6 +29,58 @@ RSpec.describe ActivityPub::Activity::Create do subject.perform end + context 'object has been edited' do + let(:object_json) do + { + id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, + type: 'Note', + content: 'Lorem ipsum', + published: '2022-01-22T15:00:00Z', + updated: '2022-01-22T16:00:00Z', + } + end + + it 'creates status' do + status = sender.statuses.first + + expect(status).to_not be_nil + expect(status.text).to eq 'Lorem ipsum' + end + + it 'marks status as edited' do + status = sender.statuses.first + + expect(status).to_not be_nil + expect(status.edited?).to eq true + end + end + + context 'object has update date equal to creation date' do + let(:object_json) do + { + id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, + type: 'Note', + content: 'Lorem ipsum', + published: '2022-01-22T15:00:00Z', + updated: '2022-01-22T15:00:00Z', + } + end + + it 'creates status' do + status = sender.statuses.first + + expect(status).to_not be_nil + expect(status.text).to eq 'Lorem ipsum' + end + + it 'does not mark status as edited' do + status = sender.statuses.first + + expect(status).to_not be_nil + expect(status.edited?).to eq false + end + end + context 'unknown object type' do let(:object_json) do { diff --git a/spec/lib/activitypub/activity/move_spec.rb b/spec/lib/activitypub/activity/move_spec.rb index 2d1d276c5..c468fdeff 100644 --- a/spec/lib/activitypub/activity/move_spec.rb +++ b/spec/lib/activitypub/activity/move_spec.rb @@ -84,9 +84,9 @@ RSpec.describe ActivityPub::Activity::Move do context 'when a Move has been recently processed' do around do |example| - Redis.current.set("move_in_progress:#{old_account.id}", true, nx: true, ex: 7.days.seconds) + redis.set("move_in_progress:#{old_account.id}", true, nx: true, ex: 7.days.seconds) example.run - Redis.current.del("move_in_progress:#{old_account.id}") + redis.del("move_in_progress:#{old_account.id}") end it 'does not set moved account on old account' do diff --git a/spec/lib/delivery_failure_tracker_spec.rb b/spec/lib/delivery_failure_tracker_spec.rb index 52a1a92f0..c8179ebd9 100644 --- a/spec/lib/delivery_failure_tracker_spec.rb +++ b/spec/lib/delivery_failure_tracker_spec.rb @@ -22,7 +22,7 @@ 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:example.com', i) } + 6.times { |i| redis.sadd('exhausted_deliveries:example.com', i) } subject.track_failure! expect(subject.days).to eq 7 diff --git a/spec/lib/feed_manager_spec.rb b/spec/lib/feed_manager_spec.rb index 2217ad272..1b04916a1 100644 --- a/spec/lib/feed_manager_spec.rb +++ b/spec/lib/feed_manager_spec.rb @@ -202,11 +202,11 @@ RSpec.describe FeedManager do account = Fabricate(:account) status = Fabricate(:status) members = FeedManager::MAX_ITEMS.times.map { |count| [count, count] } - Redis.current.zadd("feed:home:#{account.id}", members) + redis.zadd("feed:home:#{account.id}", members) FeedManager.instance.push_to_home(account, status) - expect(Redis.current.zcard("feed:home:#{account.id}")).to eq FeedManager::MAX_ITEMS + expect(redis.zcard("feed:home:#{account.id}")).to eq FeedManager::MAX_ITEMS end context 'reblogs' do @@ -431,7 +431,7 @@ RSpec.describe FeedManager do FeedManager.instance.merge_into_home(account, reblog.account) - expect(Redis.current.zscore("feed:home:0", reblog.id)).to eq nil + expect(redis.zscore("feed:home:0", reblog.id)).to eq nil end end @@ -447,13 +447,13 @@ RSpec.describe FeedManager do FeedManager.instance.push_to_home(receiver, status) # The reblogging status should show up under normal conditions. - expect(Redis.current.zrange("feed:home:#{receiver.id}", 0, -1)).to include(status.id.to_s) + expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to include(status.id.to_s) FeedManager.instance.unpush_from_home(receiver, status) # Restore original status - expect(Redis.current.zrange("feed:home:#{receiver.id}", 0, -1)).to_not include(status.id.to_s) - expect(Redis.current.zrange("feed:home:#{receiver.id}", 0, -1)).to include(reblogged.id.to_s) + expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to_not include(status.id.to_s) + expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to include(reblogged.id.to_s) end it 'removes a reblogged status if it was only reblogged once' do @@ -463,11 +463,11 @@ RSpec.describe FeedManager do FeedManager.instance.push_to_home(receiver, status) # The reblogging status should show up under normal conditions. - expect(Redis.current.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [status.id.to_s] + expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [status.id.to_s] FeedManager.instance.unpush_from_home(receiver, status) - expect(Redis.current.zrange("feed:home:#{receiver.id}", 0, -1)).to be_empty + expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to be_empty end it 'leaves a multiply-reblogged status if another reblog was in feed' do @@ -479,13 +479,13 @@ RSpec.describe FeedManager do end # The reblogging status should show up under normal conditions. - expect(Redis.current.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [reblogs.first.id.to_s] + expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [reblogs.first.id.to_s] reblogs[0...-1].each do |reblog| FeedManager.instance.unpush_from_home(receiver, reblog) end - expect(Redis.current.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [reblogs.last.id.to_s] + expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [reblogs.last.id.to_s] end it 'sends push updates' do @@ -493,11 +493,11 @@ RSpec.describe FeedManager do FeedManager.instance.push_to_home(receiver, status) - allow(Redis.current).to receive_messages(publish: nil) + allow(redis).to receive_messages(publish: nil) FeedManager.instance.unpush_from_home(receiver, status) deletion = Oj.dump(event: :delete, payload: status.id.to_s) - expect(Redis.current).to have_received(:publish).with("timeline:#{receiver.id}", deletion) + expect(redis).to have_received(:publish).with("timeline:#{receiver.id}", deletion) end end @@ -515,14 +515,14 @@ RSpec.describe FeedManager do before do [status_1, status_3, status_5, status_6, status_7].each do |status| - Redis.current.zadd("feed:home:#{account.id}", status.id, status.id) + redis.zadd("feed:home:#{account.id}", status.id, status.id) end end it 'correctly cleans the home timeline' do FeedManager.instance.clear_from_home(account, target_account) - expect(Redis.current.zrange("feed:home:#{account.id}", 0, -1)).to eq [status_1.id.to_s, status_7.id.to_s] + expect(redis.zrange("feed:home:#{account.id}", 0, -1)).to eq [status_1.id.to_s, status_7.id.to_s] end end end |