bans: add test for logging in with expired ban.

This commit is contained in:
evazion
2017-05-07 12:12:43 -05:00
parent fd291c8b42
commit 19e91f438b
2 changed files with 17 additions and 1 deletions

View File

@@ -21,6 +21,21 @@ class SessionsControllerTest < ActionController::TestCase
assert_equal(@user.id, session[:user_id])
assert_not_nil(@user.last_ip_addr)
end
should "unban user if user has expired ban" do
CurrentUser.scoped(@user, "127.0.0.1") do
@banned = FactoryGirl.create(:banned_user, ban_duration: 3)
end
travel_to(4.days.from_now) do
post :create, {name: @banned.name, password: "password"}
SessionLoader.new(session, {}, request, {}).load
assert_equal(@banned.id, session[:user_id])
assert_equal(true, @banned.ban_expired?)
assert_equal(false, @banned.reload.is_banned)
end
end
end
context "destroy action" do