FIX: Cache all flags multisite-safe (#28204)

This fixes an N1 in topics when loading all flags
and also makes the cache multisite-safe, followup
to fb7cc2d3754d23e4c30fa2794eb7ac84ffdc667e
This commit is contained in:
Martin Brennan
2024-08-06 09:59:49 +10:00
committed by GitHub
parent 3b39c798bf
commit 2225c03455
4 changed files with 87 additions and 17 deletions

View File

@ -0,0 +1,24 @@
# frozen_string_literal: true
RSpec.describe "Custom flags in multisite", type: :multisite do
describe "PostACtionType#all_flags" do
use_redis_snapshotting
it "does not share flag definitions between sites" do
flag_1 = Flag.create!(name: "test flag 1", position: 99, applies_to: ["Post"])
test_multisite_connection("second") do
flag_2 = Flag.create!(name: "test flag 2", position: 99, applies_to: ["Post"])
PostActionType.expire_cache
expect(PostActionType.all_flags.last).to eq(
flag_2.attributes.except("created_at", "updated_at").transform_keys(&:to_sym),
)
end
PostActionType.expire_cache
expect(PostActionType.all_flags.last).to eq(
flag_1.attributes.except("created_at", "updated_at").transform_keys(&:to_sym),
)
end
end
end