Skip to content

Commit

Permalink
allowing port for hostnames
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg authored and Oleg committed Oct 28, 2012
1 parent 8279ab5 commit 486c465
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/cms/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Cms::Site < ActiveRecord::Base
validates :hostname,
:presence => true,
:uniqueness => { :scope => :path },
:format => { :with => /^[\w\.\-]+$/ }
:format => { :with => /^[\w\.\-]+(?:\:\d+)?$/ }

# -- Scopes ---------------------------------------------------------------
scope :mirrored, where(:is_mirrored => true)
Expand Down
7 changes: 5 additions & 2 deletions test/unit/models/site_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class CmsSiteTest < ActiveSupport::TestCase

def test_fixtures_validity
Cms::Site.all.each do |site|
assert site.valid?, site.errors.full_messages.to_s
assert site.valid?, site.errors.inspect
end
end

Expand All @@ -22,7 +22,10 @@ def test_validation
assert_has_errors_on site, :identifier

site = Cms::Site.new(:identifier => 'test', :hostname => 'site.host')
assert site.valid?, site.errors.to_yaml
assert site.valid?, site.errors.inspect

site = Cms::Site.new(:identifier => 'test', :hostname => 'localhost:3000')
assert site.valid?, site.errors.inspect
end

def test_validation_path_uniqueness
Expand Down

0 comments on commit 486c465

Please sign in to comment.