foreman/test/unit/image_test.rb @ 783fb4aa
dd42df0a | Ohad Levy | require 'test_helper'
|
|
class ImageTest < ActiveSupport::TestCase
|
|||
e0d618ef | Joseph Magen | test "can destroy image even if used by host and ensure host image_id is nullified" do
|
|
image = images(:one)
|
|||
e14b5758 | Greg Sutcliffe | host = FactoryGirl.create(:host)
|
|
e0d618ef | Joseph Magen | host.update_attribute(:image_id, image.id)
|
|
refute_nil host.image_id
|
|||
assert_difference('Image.count', -1) do
|
|||
assert image.destroy
|
|||
end
|
|||
host.reload
|
|||
assert_nil host.image_id
|
|||
end
|
|||
4cbb4a26 | Tom Caspy | test "image is invalid if uuid invalid" do
|
|
resource = compute_resources(:one)
|
|||
image = resource.images.build(:name => "foo", :uuid => "bar")
|
|||
ComputeResource.any_instance.stubs(:image_exists?).returns(false)
|
|||
image.valid? #trigger validations
|
|||
assert image.errors.messages.keys.include?(:uuid)
|
|||
end
|
|||
dd42df0a | Ohad Levy | end
|