5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-07-02 07:56:07 +00:00

se pueden eliminar sitios

This commit is contained in:
f 2019-07-12 15:34:16 -03:00
parent 1c18064a24
commit afb68bfcbd
No known key found for this signature in database
GPG key ID: 2AE5A13E321F953D
3 changed files with 14 additions and 1 deletions

View file

@ -17,6 +17,8 @@ class Site < ApplicationRecord
# Clonar el directorio de esqueleto antes de crear el sitio
before_create :clone_skel!
# Elimina el directorio al destruir un sitio
before_destroy :remove_directories!
# Carga el sitio Jekyll una vez que se inicializa el modelo o después
# de crearlo
after_initialize :load_jekyll!
@ -363,4 +365,8 @@ class Site < ApplicationRecord
@jekyll ||= Site.load_jekyll(Dir.pwd)
end
end
def remove_directories!
FileUtils.rm_rf path
end
end

View file

@ -2,6 +2,6 @@
FactoryBot.define do
factory :site do
name { SecureRandom.hex }
name { "test-#{SecureRandom.hex}" }
end
end

View file

@ -10,6 +10,13 @@ class SiteTest < ActiveSupport::TestCase
# TODO: Mover a la validación del sitio o hacer algo similar
assert File.directory?(site.path)
assert File.directory?(File.join(site.path, '.git'))
assert site.destroy
end
test 'al destruir un sitio se eliminan los archivos' do
site = create :site
assert site.destroy
assert !File.directory?(site.path)
end
test 'se puede leer un sitio' do