mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 18:15:48 +08:00
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:
parent
4f0fe92195
commit
80449d39d3
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user