Revision f34463c4
Added by Paul Kelly almost 14 years ago
- ID f34463c46a5e1f132e9c5d1cc396e866ada0cec4
app/models/environment.rb | ||
---|---|---|
has_many :hosts
|
||
validates_presence_of :name
|
||
validates_uniqueness_of :name
|
||
validates_format_of :name, :with => /^\S+$/, :message => "cannot contain spaces"
|
||
validates_format_of :name, :with => /^[\w\d]+$/, :message => "is alphanumeric and cannot contain spaces"
|
||
default_scope :order => 'name'
|
||
|
||
def to_label
|
test/unit/environment_test.rb | ||
---|---|---|
assert !env.valid?
|
||
end
|
||
|
||
test "name should be alphanumeric" do
|
||
env = Environment.new :name => "test&fail"
|
||
assert !env.valid?
|
||
end
|
||
|
||
test "to_label should print name" do
|
||
env = Environment.new :name => "foo"
|
||
assert env.to_label == env.name
|
Also available in: Unified diff
Fixes #256 - Environment names should be alphanumeric