FIX: flaky user_merger_spec.rb (#27169)
Flag guardian spec needs to clean state after evaluation. Each created flag is adding PostActionType.
This commit is contained in:
parent
99e27c4fd5
commit
89401d5fc1
|
@ -3,12 +3,15 @@
|
||||||
RSpec.describe FlagGuardian do
|
RSpec.describe FlagGuardian do
|
||||||
fab!(:user)
|
fab!(:user)
|
||||||
fab!(:admin)
|
fab!(:admin)
|
||||||
fab!(:flag)
|
|
||||||
|
after(:each) { Flag.reset_flag_settings! }
|
||||||
|
|
||||||
describe "#can_edit_flag?" do
|
describe "#can_edit_flag?" do
|
||||||
it "returns true for admin and false for regular user" do
|
it "returns true for admin and false for regular user" do
|
||||||
|
flag = Fabricate(:flag)
|
||||||
expect(Guardian.new(admin).can_edit_flag?(flag)).to eq(true)
|
expect(Guardian.new(admin).can_edit_flag?(flag)).to eq(true)
|
||||||
expect(Guardian.new(user).can_edit_flag?(flag)).to eq(false)
|
expect(Guardian.new(user).can_edit_flag?(flag)).to eq(false)
|
||||||
|
flag.destroy!
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when flag is system" do
|
it "returns false when flag is system" do
|
||||||
|
@ -16,13 +19,17 @@ RSpec.describe FlagGuardian do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when flag was already used with post action" do
|
it "returns false when flag was already used with post action" do
|
||||||
|
flag = Fabricate(:flag)
|
||||||
Fabricate(:post_action, post_action_type_id: flag.id)
|
Fabricate(:post_action, post_action_type_id: flag.id)
|
||||||
expect(Guardian.new(admin).can_edit_flag?(flag)).to eq(false)
|
expect(Guardian.new(admin).can_edit_flag?(flag)).to eq(false)
|
||||||
|
flag.destroy!
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when flag was already used with reviewable" do
|
it "returns false when flag was already used with reviewable" do
|
||||||
|
flag = Fabricate(:flag)
|
||||||
Fabricate(:reviewable_score, reviewable_score_type: flag.id)
|
Fabricate(:reviewable_score, reviewable_score_type: flag.id)
|
||||||
expect(Guardian.new(admin).can_edit_flag?(flag)).to eq(false)
|
expect(Guardian.new(admin).can_edit_flag?(flag)).to eq(false)
|
||||||
|
flag.destroy!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue