Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
823f8b79c9
2 changed files with 17 additions and 2 deletions
|
@ -1,3 +1,5 @@
|
|||
require 'instiki_stringsupport'
|
||||
|
||||
class Web < ActiveRecord::Base
|
||||
## Associations
|
||||
|
||||
|
@ -15,8 +17,7 @@ class Web < ActiveRecord::Base
|
|||
|
||||
## Validations
|
||||
|
||||
validates_uniqueness_of :address
|
||||
|
||||
validates_uniqueness_of :address, :message => 'already exists'
|
||||
validates_length_of :color, :in => 3..6
|
||||
|
||||
## Methods
|
||||
|
@ -203,6 +204,10 @@ class Web < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def validate_address
|
||||
if ['create_system', 'create_web', 'delete_web', 'delete_files', 'web_list', ''].include?(address)
|
||||
self.errors.add(:address, 'is not a valid address')
|
||||
raise Instiki::ValidationError.new("\"#{address.purify.escapeHTML}\" #{errors.on(:address)}")
|
||||
end
|
||||
unless address == CGI.escape(address)
|
||||
self.errors.add(:address, 'should contain only valid URI characters')
|
||||
raise Instiki::ValidationError.new("#{self.class.human_attribute_name('address')} #{errors.on(:address)}")
|
||||
|
|
|
@ -56,6 +56,16 @@ class WebTest < ActiveSupport::TestCase
|
|||
assert_raises(Instiki::ValidationError) {
|
||||
Web.create(:name => 'Wiki2', :address => "wiki\234", :password => '123')
|
||||
}
|
||||
assert_raises(Instiki::ValidationError) {
|
||||
Web.create(:name => 'Wiki2', :address => "web_list", :password => '123')
|
||||
}
|
||||
assert_raises(Instiki::ValidationError) {
|
||||
Web.create(:name => 'Wiki2', :address => "", :password => '123')
|
||||
}
|
||||
assert_raises(Instiki::ValidationError) {
|
||||
Web.create!(:name => 'Wiki2', :address => "", :password => '123')
|
||||
Web.create(:name => 'Wiki2', :address => "", :password => '123')
|
||||
}
|
||||
end
|
||||
|
||||
def test_new_page_linked_from_mother_page
|
||||
|
|
Loading…
Reference in a new issue