FIX: Flaky flags spec (#28591)

Because of caching, whenever flags are created, they have to be destroyed to not modify the state.
This commit is contained in:
Krzysztof Kotlarek 2024-08-28 17:03:43 +10:00 committed by GitHub
parent 4f0fe92195
commit 80449d39d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 8 deletions

View File

@ -13,10 +13,12 @@ RSpec.describe FlagGuardian do
expect(Guardian.new(admin).can_create_flag?).to eq(true) expect(Guardian.new(admin).can_create_flag?).to eq(true)
expect(Guardian.new(user).can_create_flag?).to eq(false) expect(Guardian.new(user).can_create_flag?).to eq(false)
Fabricate(:flag) flag = Fabricate(:flag)
expect(Guardian.new(admin).can_create_flag?).to eq(false) expect(Guardian.new(admin).can_create_flag?).to eq(false)
expect(Guardian.new(user).can_create_flag?).to eq(false) expect(Guardian.new(user).can_create_flag?).to eq(false)
flag.destroy!
end end
end end

View File

@ -16,16 +16,12 @@ RSpec.describe FlagSerializer do
end end
context "when custom flag" do context "when custom flag" do
fab!(:flag) { Fabricate(:flag, name: "custom title", description: "custom description") } it "returns translated name and description" do
flag = Fabricate(:flag, name: "custom title", description: "custom description")
it "returns translated name" do
serialized = described_class.new(flag, used_flag_ids: []).as_json serialized = described_class.new(flag, used_flag_ids: []).as_json
expect(serialized[:flag][:name]).to eq("custom title") expect(serialized[:flag][:name]).to eq("custom title")
end
it "returns translated description" do
serialized = described_class.new(flag, used_flag_ids: []).as_json
expect(serialized[:flag][:description]).to eq("custom description") expect(serialized[:flag][:description]).to eq("custom description")
flag.destroy!
end end
end end