A platform for community discussion. Free, open, simple.
FIX: Category type registry causing flaky specs (#38853)
Martin Brennan380294e4feac
diff --git a/app/services/categories/type_registry.rb b/app/services/categories/type_registry.rbindex 736921d1ab4..7bf5637aac0 100644--- a/app/services/categories/type_registry.rb+++ b/app/services/categories/type_registry.rb@@ -42,6 +42,10 @@ module Categoriesdef reset!@types = nil@owners = nil++ # Always need to re-register the core Discussion type, the system doesn't work+ # without it.+ self.register(Categories::Types::Discussion)end# Returns all the category type counts in a hash with the typediff --git a/spec/services/categories/type_registry_spec.rb b/spec/services/categories/type_registry_spec.rbindex c530dd854de..4680e2c7ae1 100644--- a/spec/services/categories/type_registry_spec.rb+++ b/spec/services/categories/type_registry_spec.rb@@ -60,10 +60,10 @@ RSpec.describe Categories::TypeRegistry doexpect(queries.size).to eq(1)end- it "returns empty hash when no types are registered" do+ it "returns only the core discussion type in the hash when no other types are registered" dooriginal_types = described_class.all.dupdescribed_class.reset!- expect(described_class.counts).to eq({})+ expect(described_class.counts).to eq({ discussion: 0 })ensureoriginal_types&.each_value { |klass| described_class.register(klass) }end