DEV: Fix flaky specs related to flag services

Creating or updating flags generates global side effects. Sometimes it
seems the state can leak from the flag specs.

This is probably related to the use of `fab!`. This patch replaces those
calls with standard `let`s. While the overall performances of these
tests will be a little less good, their state should not leak anymore.
This commit is contained in:
Loïc Guitaut 2024-10-18 17:19:43 +02:00 committed by Loïc Guitaut
parent fe4e2a17cb
commit 64605519da
3 changed files with 3 additions and 3 deletions

View File

@ -3,9 +3,9 @@
RSpec.describe(Flags::DestroyFlag) do
subject(:result) { described_class.call(**params, **dependencies) }
fab!(:flag)
fab!(:current_user) { Fabricate(:admin) }
let(:flag) { Fabricate(:flag) }
let(:params) { { id: flag_id } }
let(:dependencies) { { guardian: current_user.guardian } }
let(:flag_id) { flag.id }

View File

@ -8,9 +8,9 @@ RSpec.describe(Flags::ToggleFlag) do
describe ".call" do
subject(:result) { described_class.call(**params, **dependencies) }
fab!(:flag)
fab!(:current_user) { Fabricate(:admin) }
let(:flag) { Fabricate(:flag) }
let(:flag_id) { flag.id }
let(:params) { { flag_id: flag_id } }
let(:dependencies) { { guardian: current_user.guardian } }

View File

@ -13,9 +13,9 @@ RSpec.describe(Flags::UpdateFlag) do
describe ".call" do
subject(:result) { described_class.call(**params, **dependencies) }
fab!(:flag)
fab!(:current_user) { Fabricate(:admin) }
let(:flag) { Fabricate(:flag) }
let(:params) { { id: flag_id, name:, description:, applies_to:, require_message:, enabled: } }
let(:dependencies) { { guardian: current_user.guardian } }
let(:flag_id) { flag.id }