Project

General

Profile

« Previous | Next » 

Revision 1e4b330b

Added by Lucas Tolchinsky over 14 years ago

  • ID 1e4b330bd20897a594e0e52a980f73dcf75dc6b0

added test for before_destroy on architecture

View differences:

app/models/architecture.rb
has_many :hosts
has_and_belongs_to_many :operatingsystem
validates_uniqueness_of :name
before_destroy :ensure_not_used
before_destroy Ensure_not_used_by.new(:hosts)
validates_format_of :name, :with => /\A(\S+)\Z/, :message => "can't be blank or contain white spaces."
def to_s
test/unit/architecture_test.rb
architecture = Architecture.new :name => "i386"
assert architecture.to_s == architecture.name
end
test "should not destroy while using" do
architecture = Architecture.new :name => "i386"
assert architecture.save
host = Host.new :name => "myfullhost", :mac => "aabbecddeeff", :ip => "123.05.02.03",
:domain => Domain.find_or_create_by_name("company.com"), :operatingsystem => Operatingsystem.first,
:architecture => architecture, :environment => Environment.first, :disk => "empty partition",
:ptable => Ptable.first
assert host.save!
architecture.hosts << host
assert !architecture.destroy
end
end

Also available in: Unified diff