diff --git a/app/models/site.rb b/app/models/site.rb index d81b95f9..e82a347b 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -9,7 +9,10 @@ class Site < ApplicationRecord # @see app/services/site_service.rb DEPLOYS = %i[local www zip].freeze - validates :name, uniqueness: true, hostname: true + validates :name, uniqueness: true, hostname: { + allow_root_label: true + } + validates :design_id, presence: true validate :deploy_local_presence validates_inclusion_of :status, in: %w[waiting enqueued building] diff --git a/app/views/sites/_form.haml b/app/views/sites/_form.haml index 0afb3ada..60e5a8de 100644 --- a/app/views/sites/_form.haml +++ b/app/views/sites/_form.haml @@ -10,7 +10,7 @@ = f.text_field :name, class: form_control(site, :name), required: true, - pattern: '^([a-z0-9][a-z0-9\-]*)?[a-z0-9]$', + pattern: '^([a-z0-9][a-z0-9\-]*)?[a-z0-9\.]$', minlength: 1, maxlength: 63 - if invalid? site, :name diff --git a/test/models/site_test.rb b/test/models/site_test.rb index 78e3f577..bb6a4777 100644 --- a/test/models/site_test.rb +++ b/test/models/site_test.rb @@ -32,11 +32,11 @@ class SiteTest < ActiveSupport::TestCase assert_not site.errors.messages[:name].present? end - test 'el nombre del sitio no puede terminar con punto' do + test 'el nombre del sitio puede terminar con punto' do site = build :site, name: 'hola.chau.' site.validate - assert site.errors.messages[:name].present? + assert_not site.errors.messages[:name].present? end test 'el nombre del sitio no puede contener wildcard' do