Project

General

Profile

Download (1.26 KB) Statistics
| Branch: | Tag: | Revision:
c6e02bd3 Joseph Magen
require 'test_helper'

class ComputeProfileTest < ActiveSupport::TestCase
setup do
e07f9a12 Dominic Cleal
User.current = users :admin
c6e02bd3 Joseph Magen
end

test "name can't be blank" do
cp = ComputeProfile.new :name => " "
assert !cp.save
end

test "name must be unique" do
cp = ComputeProfile.new :name => "1-Small"
assert !cp.save
end

test "should not destroy if in use by hostgroup" do
#hostgroups(:common) uses compute_profiles(:one)
assert !compute_profiles(:one).destroy
end

e0d618ef Joseph Magen
test "can destroy if used by host, but not hostgroup, and ensure host.compute_profile_id is nullified" do
compute_profile = compute_profiles(:two)
e14b5758 Greg Sutcliffe
host = FactoryGirl.create(:host, :compute_profile => compute_profile)
e0d618ef Joseph Magen
assert_difference('ComputeProfile.count', -1) do
assert compute_profile.destroy
end
host.reload
assert_nil host.compute_profile_id
end

c6e02bd3 Joseph Magen
test "shoud show visible hw profiles only" do
cfd1c413 Tomas Strachota
assert_equal 4, ComputeProfile.count
c6e02bd3 Joseph Magen
#3-Large does not have any data in compute_attributes.yml
cfd1c413 Tomas Strachota
assert_equal 3, ComputeProfile.visibles.count
c6e02bd3 Joseph Magen
end

6e7682a9 Sam Kottler
test "compute profile with associated attributes can be destroyed" do
cfd1c413 Tomas Strachota
assert_difference('ComputeAttribute.count', -2) do
6e7682a9 Sam Kottler
assert compute_attributes(:three).compute_profile.destroy
end
end
c6e02bd3 Joseph Magen
end