Merge branch 'main' into glitch-soc/merge-upstream
This commit is contained in:
@ -65,22 +65,22 @@ describe ApplicationController, type: :controller do
|
||||
get :show
|
||||
|
||||
expect_updated_sign_in_at(user)
|
||||
expect(Redis.current.get("account:#{user.account_id}:regeneration")).to eq 'true'
|
||||
expect(redis.get("account:#{user.account_id}:regeneration")).to eq 'true'
|
||||
expect(RegenerationWorker).to have_received(:perform_async)
|
||||
end
|
||||
|
||||
it 'sets the regeneration marker to expire' do
|
||||
allow(RegenerationWorker).to receive(:perform_async)
|
||||
get :show
|
||||
expect(Redis.current.ttl("account:#{user.account_id}:regeneration")).to be >= 0
|
||||
expect(redis.ttl("account:#{user.account_id}:regeneration")).to be >= 0
|
||||
end
|
||||
|
||||
it 'regenerates feed when sign in is older than two weeks' do
|
||||
get :show
|
||||
|
||||
expect_updated_sign_in_at(user)
|
||||
expect(Redis.current.zcard(FeedManager.instance.key(:home, user.account_id))).to eq 3
|
||||
expect(Redis.current.get("account:#{user.account_id}:regeneration")).to be_nil
|
||||
expect(redis.zcard(FeedManager.instance.key(:home, user.account_id))).to eq 3
|
||||
expect(redis.get("account:#{user.account_id}:regeneration")).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -15,7 +15,7 @@ RSpec.describe HomeFeed, type: :model do
|
||||
|
||||
context 'when feed is generated' do
|
||||
before do
|
||||
Redis.current.zadd(
|
||||
redis.zadd(
|
||||
FeedManager.instance.key(:home, account.id),
|
||||
[[4, 4], [3, 3], [2, 2], [1, 1]]
|
||||
)
|
||||
@ -31,7 +31,7 @@ RSpec.describe HomeFeed, type: :model do
|
||||
|
||||
context 'when feed is being generated' do
|
||||
before do
|
||||
Redis.current.set("account:#{account.id}:regeneration", true)
|
||||
redis.set("account:#{account.id}:regeneration", true)
|
||||
end
|
||||
|
||||
it 'returns nothing' do
|
||||
|
@ -13,7 +13,6 @@ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
||||
|
||||
ActiveRecord::Migration.maintain_test_schema!
|
||||
WebMock.disable_net_connect!(allow: Chewy.settings[:host])
|
||||
Redis.current = Redis::Namespace.new("mastodon_test#{ENV['TEST_ENV_NUMBER']}", redis: Redis.current)
|
||||
Sidekiq::Testing.inline!
|
||||
Sidekiq.logger = nil
|
||||
|
||||
@ -44,6 +43,7 @@ RSpec.configure do |config|
|
||||
config.include Devise::Test::ControllerHelpers, type: :view
|
||||
config.include Paperclip::Shoulda::Matchers
|
||||
config.include ActiveSupport::Testing::TimeHelpers
|
||||
config.include Redisable
|
||||
|
||||
config.before :each, type: :feature do
|
||||
https = ENV['LOCAL_HTTPS'] == 'true'
|
||||
@ -60,7 +60,7 @@ RSpec.configure do |config|
|
||||
|
||||
config.after :each do
|
||||
Rails.cache.clear
|
||||
Redis.current.del(Redis.current.keys)
|
||||
redis.del(redis.keys)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -14,7 +14,7 @@ RSpec.describe AfterBlockService, type: :service do
|
||||
let(:home_timeline_key) { FeedManager.instance.key(:home, account.id) }
|
||||
|
||||
before do
|
||||
Redis.current.del(home_timeline_key)
|
||||
redis.del(home_timeline_key)
|
||||
end
|
||||
|
||||
it "clears account's statuses" do
|
||||
@ -23,7 +23,7 @@ RSpec.describe AfterBlockService, type: :service do
|
||||
FeedManager.instance.push_to_home(account, other_account_reblog)
|
||||
|
||||
expect { subject }.to change {
|
||||
Redis.current.zrange(home_timeline_key, 0, -1)
|
||||
redis.zrange(home_timeline_key, 0, -1)
|
||||
}.from([status.id.to_s, other_account_status.id.to_s, other_account_reblog.id.to_s]).to([other_account_status.id.to_s])
|
||||
end
|
||||
end
|
||||
@ -33,7 +33,7 @@ RSpec.describe AfterBlockService, type: :service do
|
||||
let(:list_timeline_key) { FeedManager.instance.key(:list, list.id) }
|
||||
|
||||
before do
|
||||
Redis.current.del(list_timeline_key)
|
||||
redis.del(list_timeline_key)
|
||||
end
|
||||
|
||||
it "clears account's statuses" do
|
||||
@ -42,7 +42,7 @@ RSpec.describe AfterBlockService, type: :service do
|
||||
FeedManager.instance.push_to_list(list, other_account_reblog)
|
||||
|
||||
expect { subject }.to change {
|
||||
Redis.current.zrange(list_timeline_key, 0, -1)
|
||||
redis.zrange(list_timeline_key, 0, -1)
|
||||
}.from([status.id.to_s, other_account_status.id.to_s, other_account_reblog.id.to_s]).to([other_account_status.id.to_s])
|
||||
end
|
||||
end
|
||||
|
@ -12,7 +12,7 @@ RSpec.describe BatchedRemoveStatusService, type: :service do
|
||||
let(:status2) { PostStatusService.new.call(alice, text: 'Another status') }
|
||||
|
||||
before do
|
||||
allow(Redis.current).to receive_messages(publish: nil)
|
||||
allow(redis).to receive_messages(publish: nil)
|
||||
|
||||
stub_request(:post, 'http://example.com/inbox').to_return(status: 200)
|
||||
|
||||
@ -40,11 +40,11 @@ RSpec.describe BatchedRemoveStatusService, type: :service do
|
||||
end
|
||||
|
||||
it 'notifies streaming API of followers' do
|
||||
expect(Redis.current).to have_received(:publish).with("timeline:#{jeff.id}", any_args).at_least(:once)
|
||||
expect(redis).to have_received(:publish).with("timeline:#{jeff.id}", any_args).at_least(:once)
|
||||
end
|
||||
|
||||
it 'notifies streaming API of public timeline' do
|
||||
expect(Redis.current).to have_received(:publish).with('timeline:public', any_args).at_least(:once)
|
||||
expect(redis).to have_received(:publish).with('timeline:public', any_args).at_least(:once)
|
||||
end
|
||||
|
||||
it 'sends delete activity to followers' do
|
||||
|
@ -18,7 +18,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
|
||||
ProcessMentionsService.new.call(status)
|
||||
ProcessHashtagsService.new.call(status)
|
||||
|
||||
allow(Redis.current).to receive(:publish)
|
||||
allow(redis).to receive(:publish)
|
||||
|
||||
subject.call(status)
|
||||
end
|
||||
@ -40,13 +40,13 @@ RSpec.describe FanOutOnWriteService, type: :service do
|
||||
end
|
||||
|
||||
it 'is broadcast to the hashtag stream' do
|
||||
expect(Redis.current).to have_received(:publish).with('timeline:hashtag:hoge', anything)
|
||||
expect(Redis.current).to have_received(:publish).with('timeline:hashtag:hoge:local', anything)
|
||||
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything)
|
||||
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge:local', anything)
|
||||
end
|
||||
|
||||
it 'is broadcast to the public stream' do
|
||||
expect(Redis.current).to have_received(:publish).with('timeline:public', anything)
|
||||
expect(Redis.current).to have_received(:publish).with('timeline:public:local', anything)
|
||||
expect(redis).to have_received(:publish).with('timeline:public', anything)
|
||||
expect(redis).to have_received(:publish).with('timeline:public:local', anything)
|
||||
end
|
||||
end
|
||||
|
||||
@ -66,8 +66,8 @@ RSpec.describe FanOutOnWriteService, type: :service do
|
||||
end
|
||||
|
||||
it 'is not broadcast publicly' do
|
||||
expect(Redis.current).to_not have_received(:publish).with('timeline:hashtag:hoge', anything)
|
||||
expect(Redis.current).to_not have_received(:publish).with('timeline:public', anything)
|
||||
expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge', anything)
|
||||
expect(redis).to_not have_received(:publish).with('timeline:public', anything)
|
||||
end
|
||||
end
|
||||
|
||||
@ -84,8 +84,8 @@ RSpec.describe FanOutOnWriteService, type: :service do
|
||||
end
|
||||
|
||||
it 'is not broadcast publicly' do
|
||||
expect(Redis.current).to_not have_received(:publish).with('timeline:hashtag:hoge', anything)
|
||||
expect(Redis.current).to_not have_received(:publish).with('timeline:public', anything)
|
||||
expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge', anything)
|
||||
expect(redis).to_not have_received(:publish).with('timeline:public', anything)
|
||||
end
|
||||
end
|
||||
|
||||
@ -105,8 +105,8 @@ RSpec.describe FanOutOnWriteService, type: :service do
|
||||
end
|
||||
|
||||
it 'is not broadcast publicly' do
|
||||
expect(Redis.current).to_not have_received(:publish).with('timeline:hashtag:hoge', anything)
|
||||
expect(Redis.current).to_not have_received(:publish).with('timeline:public', anything)
|
||||
expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge', anything)
|
||||
expect(redis).to_not have_received(:publish).with('timeline:public', anything)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -12,7 +12,7 @@ RSpec.describe MuteService, type: :service do
|
||||
let(:home_timeline_key) { FeedManager.instance.key(:home, account.id) }
|
||||
|
||||
before do
|
||||
Redis.current.del(home_timeline_key)
|
||||
redis.del(home_timeline_key)
|
||||
end
|
||||
|
||||
it "clears account's statuses" do
|
||||
@ -20,7 +20,7 @@ RSpec.describe MuteService, type: :service do
|
||||
FeedManager.instance.push_to_home(account, other_account_status)
|
||||
|
||||
expect { subject }.to change {
|
||||
Redis.current.zrange(home_timeline_key, 0, -1)
|
||||
redis.zrange(home_timeline_key, 0, -1)
|
||||
}.from([status.id.to_s, other_account_status.id.to_s]).to([other_account_status.id.to_s])
|
||||
end
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ RSpec.describe PrecomputeFeedService, type: :service do
|
||||
|
||||
subject.call(account)
|
||||
|
||||
expect(Redis.current.zscore(FeedManager.instance.key(:home, account.id), status.id)).to be_within(0.1).of(status.id.to_f)
|
||||
expect(redis.zscore(FeedManager.instance.key(:home, account.id), status.id)).to be_within(0.1).of(status.id.to_f)
|
||||
end
|
||||
|
||||
it 'does not raise an error even if it could not find any status' do
|
||||
@ -30,7 +30,7 @@ RSpec.describe PrecomputeFeedService, type: :service do
|
||||
|
||||
subject.call(account)
|
||||
|
||||
expect(Redis.current.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to eq nil
|
||||
expect(redis.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to eq nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -7,17 +7,17 @@ describe Scheduler::FeedCleanupScheduler do
|
||||
let!(:inactive_user) { Fabricate(:user, current_sign_in_at: 22.days.ago) }
|
||||
|
||||
it 'clears feeds of inactives' do
|
||||
Redis.current.zadd(feed_key_for(inactive_user), 1, 1)
|
||||
Redis.current.zadd(feed_key_for(active_user), 1, 1)
|
||||
Redis.current.zadd(feed_key_for(inactive_user, 'reblogs'), 2, 2)
|
||||
Redis.current.sadd(feed_key_for(inactive_user, 'reblogs:2'), 3)
|
||||
redis.zadd(feed_key_for(inactive_user), 1, 1)
|
||||
redis.zadd(feed_key_for(active_user), 1, 1)
|
||||
redis.zadd(feed_key_for(inactive_user, 'reblogs'), 2, 2)
|
||||
redis.sadd(feed_key_for(inactive_user, 'reblogs:2'), 3)
|
||||
|
||||
subject.perform
|
||||
|
||||
expect(Redis.current.zcard(feed_key_for(inactive_user))).to eq 0
|
||||
expect(Redis.current.zcard(feed_key_for(active_user))).to eq 1
|
||||
expect(Redis.current.exists?(feed_key_for(inactive_user, 'reblogs'))).to be false
|
||||
expect(Redis.current.exists?(feed_key_for(inactive_user, 'reblogs:2'))).to be false
|
||||
expect(redis.zcard(feed_key_for(inactive_user))).to eq 0
|
||||
expect(redis.zcard(feed_key_for(active_user))).to eq 1
|
||||
expect(redis.exists?(feed_key_for(inactive_user, 'reblogs'))).to be false
|
||||
expect(redis.exists?(feed_key_for(inactive_user, 'reblogs:2'))).to be false
|
||||
end
|
||||
|
||||
def feed_key_for(user, subtype = nil)
|
||||
|
Reference in New Issue
Block a user