Merge pull request #3838 from evazion/fix-3837

Fix #3837: Remove expired bans.
This commit is contained in:
Albert Yi
2018-09-05 12:03:46 -07:00
committed by GitHub
3 changed files with 20 additions and 0 deletions

View File

@@ -29,5 +29,18 @@ class DailyMaintenanceTest < ActiveSupport::TestCase
assert(true, @pending.reload.is_deleted)
assert(true, @flagged.reload.is_deleted)
end
context "when pruning bans" do
should "clear the is_banned flag for users who are no longer banned" do
banner = FactoryBot.create(:admin_user)
user = FactoryBot.create(:user)
CurrentUser.as(banner) { FactoryBot.create(:ban, user: user, banner: banner, duration: 1) }
assert_equal(true, user.reload.is_banned)
travel_to(2.days.from_now) { DailyMaintenance.new.run }
assert_equal(false, user.reload.is_banned)
end
end
end
end