From 58f3a2e9a9a33d464e3db226d80edf19aaf1bee8 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 6 Jan 2017 15:25:49 +0800 Subject: [PATCH] Fix randomly failing spec. --- spec/components/guardian_spec.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rb index 5a950fc1cfc..346265a7187 100644 --- a/spec/components/guardian_spec.rb +++ b/spec/components/guardian_spec.rb @@ -1560,8 +1560,12 @@ describe Guardian do end it 'should not allow an admin to grant admin access to a non real user' do - Discourse.system_user.update!(admin: false) - expect(Guardian.new(admin).can_grant_admin?(Discourse.system_user)).to be(false) + begin + Discourse.system_user.update!(admin: false) + expect(Guardian.new(admin).can_grant_admin?(Discourse.system_user)).to be(false) + ensure + Discourse.system_user.update!(admin: true) + end end end @@ -1586,7 +1590,6 @@ describe Guardian do end it "should not allow an admin to revoke a no real user's admin access" do - Discourse.system_user.update!(admin: true) expect(Guardian.new(admin).can_revoke_admin?(Discourse.system_user)).to be(false) end end @@ -1614,8 +1617,12 @@ describe Guardian do end it "should not allow an admin to grant moderation to a non real user" do - Discourse.system_user.update!(moderator: false) - expect(Guardian.new(admin).can_grant_moderation?(Discourse.system_user)).to be(false) + begin + Discourse.system_user.update!(moderator: false) + expect(Guardian.new(admin).can_grant_moderation?(Discourse.system_user)).to be(false) + ensure + Discourse.system_user.update!(moderator: true) + end end end @@ -1646,7 +1653,6 @@ describe Guardian do end it "should not allow an admin to revoke moderation from a non real user" do - Discourse.system_user.update!(moderator: true) expect(Guardian.new(admin).can_revoke_moderation?(Discourse.system_user)).to be(false) end end