2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-08-17 18:04:11 +08:00

DEV: adds unregister_locale (#32676)

Running this spec locally I was getting an error:

```
  1) translate accelerator plugins loads plural rules from plugins
     Failure/Error: DiscoursePluginRegistry.unregister_locale("foo")

     NoMethodError:
       undefined method `unregister_locale' for class DiscoursePluginRegistry
     # ./spec/lib/freedom_patches/translate_accelerator_spec.rb:113:in `block (3 levels) in <main>'

Finished in 0.17998 seconds (files took 1.88 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/lib/freedom_patches/translate_accelerator_spec.rb:117 # translate accelerator plugins loads plural rules from plugins
```

On top of this, this spec was flakey, Im not sure this is going to fix
flakyness, but this seems like a good first step.
This commit is contained in:
Joffrey JAFFEUX 2025-05-10 19:50:00 +02:00 committed by GitHub
parent 7f2233b1d3
commit da111d87bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -168,6 +168,12 @@ class DiscoursePluginRegistry
self.locales[locale] = options
end
def self.unregister_locale(locale)
raise "unregister_locale can only be used in tests" if !Rails.env.test?
self.locales.delete(locale)
end
def register_archetype(name, options = {})
Archetype.register(name, options)
end

View file

@ -110,7 +110,7 @@ RSpec.describe "translate accelerator" do
end
after do
DiscoursePluginRegistry.reset!
DiscoursePluginRegistry.unregister_locale("foo")
LocaleSiteSetting.reset!
end