method for unbanning

This commit is contained in:
Kyle Drake 2019-12-18 20:58:59 -08:00
parent 82462b2461
commit 0afe4f6df3
2 changed files with 23 additions and 0 deletions

View file

@ -505,6 +505,14 @@ class Site < Sequel::Model
is_banned
end
def unban!
undelete!
self.is_banned = false
self.banned_at = nil
self.blackbox_whitelisted = true
save validate: false
end
def ban!
if username.nil? || username.empty?
raise 'username is missing'

View file

@ -14,6 +14,21 @@ describe Site do
end
end
describe 'unban' do
it 'works' do
site = Fabricate :site
index_path = File.join site.base_files_path, 'index.html'
site.ban!
File.exist?(index_path).must_equal false
site.unban!
site.reload
site.is_banned.must_equal false
site.banned_at.must_be_nil
site.blackbox_whitelisted.must_equal true
File.exist?(index_path).must_equal true
end
end
describe 'directory create' do
it 'handles wacky pathnames' do
['/derp', '/derp/'].each do |path|