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:
Krzysztof Kotlarek 2024-05-24 15:23:59 +10:00 committed by GitHub
parent 99e27c4fd5
commit 89401d5fc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 1 deletions

View File

@ -3,12 +3,15 @@
RSpec.describe FlagGuardian do
fab!(:user)
fab!(:admin)
fab!(:flag)
after(:each) { Flag.reset_flag_settings! }
describe "#can_edit_flag?" 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(user).can_edit_flag?(flag)).to eq(false)
flag.destroy!
end
it "returns false when flag is system" do
@ -16,13 +19,17 @@ RSpec.describe FlagGuardian do
end
it "returns false when flag was already used with post action" do
flag = Fabricate(:flag)
Fabricate(:post_action, post_action_type_id: flag.id)
expect(Guardian.new(admin).can_edit_flag?(flag)).to eq(false)
flag.destroy!
end
it "returns false when flag was already used with reviewable" do
flag = Fabricate(:flag)
Fabricate(:reviewable_score, reviewable_score_type: flag.id)
expect(Guardian.new(admin).can_edit_flag?(flag)).to eq(false)
flag.destroy!
end
end
end