From 2419982ef53365bcc320fec27bebc44b096806c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Tue, 6 Oct 2026 15:33:04 +0200 Subject: [PATCH] Stabilize flaky remoteStorage Redis spec "stores a token in redis" asserted an exact count of Redis keys for the user, but database cleanup only covers SQL and Redis keys accumulate across examples and spec files. It also relied on a previously-run example having created the authorization, so it failed depending on test order and leftover state. Clear the authorizations:* namespace before each example in the #create group, create the authorization under test, and assert on its specific token key instead of a global count. --- spec/models/remote_storage_authorization_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/models/remote_storage_authorization_spec.rb b/spec/models/remote_storage_authorization_spec.rb index 2db3d7d..1791ab2 100644 --- a/spec/models/remote_storage_authorization_spec.rb +++ b/spec/models/remote_storage_authorization_spec.rb @@ -11,6 +11,7 @@ RSpec.describe RemoteStorageAuthorization, type: :model do end describe "#create" do + before(:each) { redis_rs_delete_keys("authorizations:*") } after(:each) { clear_enqueued_jobs } after(:all) { redis_rs_delete_keys("authorizations:*") } @@ -27,10 +28,9 @@ RSpec.describe RemoteStorageAuthorization, type: :model do end it "stores a token in redis" do - user_auth_keys = redis_rs.keys("authorizations:#{user.cn}:*") - expect(user_auth_keys.length).to eq(1) + auth - authorizations = redis_rs.smembers(user_auth_keys.first) + authorizations = redis_rs.smembers("authorizations:#{user.cn}:#{auth.token}") expect(authorizations.sort).to eq(%w(documents photos contacts:rw videos:r tasks/work:r).sort) end -- 2.50.1