mirror of
https://github.com/neocities/neocities.git
synced 2025-08-16 06:13:54 +02:00
method for unbanning
This commit is contained in:
parent
82462b2461
commit
0afe4f6df3
2 changed files with 23 additions and 0 deletions
|
@ -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'
|
||||
|
|
|
@ -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|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue