DEV: Remove the use of stubs. (#14142)

DEV: Remove the use of stubs. (#14142)

Follow-up to 419d71abcb814b14c15918190405428bfb543548

diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rb
index 6e32926..e3ef79e 100644
--- a/spec/components/guardian_spec.rb
+++ b/spec/components/guardian_spec.rb
@@ -2522,14 +2522,14 @@ describe Guardian do
 
       it "is true if user's first post is newer than delete_user_max_post_age days old" do
         user = Fabricate(:user, created_at: 100.days.ago)
-        user.stubs(:first_post_created_at).returns(9.days.ago)
+        user.user_stat.update!(first_post_created_at: 9.days.ago)
         SiteSetting.delete_user_max_post_age = 10
         expect(Guardian.new(actor).can_delete_all_posts?(user)).to be_truthy
       end
 
       it "is false if user's first post is older than delete_user_max_post_age days old" do
         user = Fabricate(:user, created_at: 100.days.ago)
-        user.stubs(:first_post_created_at).returns(11.days.ago)
+        user.user_stat.update!(first_post_created_at: 11.days.ago)
         SiteSetting.delete_user_max_post_age = 10
         expect(Guardian.new(actor).can_delete_all_posts?(user)).to be_falsey
       end
@@ -2539,17 +2539,17 @@ describe Guardian do
       end
 
       it "is true if number of posts is small" do
-        u = Fabricate(:user, created_at: 1.day.ago)
-        u.stubs(:post_count).returns(1)
+        user = Fabricate(:user, created_at: 1.day.ago)
+        user.user_stat.update!(post_count: 1)
         SiteSetting.delete_all_posts_max = 10
-        expect(Guardian.new(actor).can_delete_all_posts?(u)).to be_truthy
+        expect(Guardian.new(actor).can_delete_all_posts?(user)).to be_truthy
       end
 
       it "is false if number of posts is not small" do
-        u = Fabricate(:user, created_at: 1.day.ago)
-        u.stubs(:post_count).returns(11)
+        user = Fabricate(:user, created_at: 1.day.ago)
+        user.user_stat.update!(post_count: 11)
         SiteSetting.delete_all_posts_max = 10
-        expect(Guardian.new(actor).can_delete_all_posts?(u)).to be_falsey
+        expect(Guardian.new(actor).can_delete_all_posts?(user)).to be_falsey
       end
     end
 

GitHub sha: d2fe46d476cb3d7e8b4ead3cb87b1b8c9440efa4

This commit appears in #14142 which was approved by techAPJ. It was merged by tgxworld.