DEV: Clean up state to prevent flaky tests (#27397)
When adding custom translations for tests using `I18n.backend.store_translations`, we need to remove the custom translations at the end of each test to prevent the custom translations from leaking to other tests.
This commit is contained in:
parent
1fbc1cd326
commit
8f55cd85ad
|
@ -5,6 +5,7 @@ describe DiscourseAutomation::AdminAutomationsController do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
SiteSetting.discourse_automation_enabled = true
|
SiteSetting.discourse_automation_enabled = true
|
||||||
|
|
||||||
I18n.backend.store_translations(
|
I18n.backend.store_translations(
|
||||||
:en,
|
:en,
|
||||||
{
|
{
|
||||||
|
@ -24,6 +25,8 @@ describe DiscourseAutomation::AdminAutomationsController do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
after { I18n.backend.reload! }
|
||||||
|
|
||||||
describe "#show" do
|
describe "#show" do
|
||||||
context "when logged in as an admin" do
|
context "when logged in as an admin" do
|
||||||
before { sign_in(Fabricate(:admin)) }
|
before { sign_in(Fabricate(:admin)) }
|
||||||
|
|
|
@ -41,6 +41,7 @@ describe DiscourseAutomation::AutomationSerializer do
|
||||||
DiscourseAutomation::Scriptable.add("foo") do
|
DiscourseAutomation::Scriptable.add("foo") do
|
||||||
field :bar, component: :text, triggerable: DiscourseAutomation::Triggers::TOPIC
|
field :bar, component: :text, triggerable: DiscourseAutomation::Triggers::TOPIC
|
||||||
end
|
end
|
||||||
|
|
||||||
I18n.backend.store_translations(
|
I18n.backend.store_translations(
|
||||||
:en,
|
:en,
|
||||||
{
|
{
|
||||||
|
@ -56,6 +57,8 @@ describe DiscourseAutomation::AutomationSerializer do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
after { I18n.backend.reload! }
|
||||||
|
|
||||||
context "when automation is not using the specific trigger" do
|
context "when automation is not using the specific trigger" do
|
||||||
fab!(:automation) do
|
fab!(:automation) do
|
||||||
Fabricate(
|
Fabricate(
|
||||||
|
@ -72,6 +75,7 @@ describe DiscourseAutomation::AutomationSerializer do
|
||||||
scope: Guardian.new(user),
|
scope: Guardian.new(user),
|
||||||
root: false,
|
root: false,
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(serializer.script[:templates]).to eq([])
|
expect(serializer.script[:templates]).to eq([])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue