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

Follow-up to 419d71abcb
This commit is contained in:
Alan Guo Xiang Tan 2021-08-25 13:25:01 +08:00 committed by GitHub
parent 58e9fffe4c
commit d2fe46d476
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -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