Revision 1e6a9256
Added by Lucas Tolchinsky over 14 years ago
- ID 1e6a9256e3e79a617e2a10f5555d0fc5e28a3479
app/models/architecture.rb | ||
---|---|---|
has_and_belongs_to_many :operatingsystem
|
||
validates_uniqueness_of :name
|
||
before_destroy :ensure_not_used
|
||
validates_format_of :name, :with => /\S+/, :message => "can't be blank or contain white spaces."
|
||
validates_format_of :name, :with => /\A(\S+)\Z/, :message => "can't be blank or contain white spaces."
|
||
|
||
def to_s
|
||
name
|
test/unit/architecture_test.rb | ||
---|---|---|
end
|
||
|
||
test "name should not contain white spaces" do
|
||
architecture = Architecture.new :name => " "
|
||
architecture = Architecture.new :name => " i38 6 "
|
||
assert !architecture.name.strip.tr(' ', '').empty?
|
||
assert !architecture.save
|
||
|
||
architecture = Architecture.new :name => " "
|
||
assert architecture.name.strip.tr(' ', '').empty?
|
||
assert !architecture.save
|
||
end
|
||
|
||
test "to_s retrives name" do
|
||
architecture = Architecture.new :name => "i386"
|
||
assert architecture.to_s == architecture.name
|
||
end
|
||
end
|
Also available in: Unified diff
improved tests and corrected validation