[email protected] wrote:
> From: Tomas Sedovic <[email protected]>
>
> Some of the tests are failing.
>   
I just pushed my PortalPool -> Pool rename. Could you rebase these 
patches and re-send? Also you'll need to replace any instance of 
PortalPool with Pool and portal_pool with pool.

In addition one of the tests is failing with a 'stack too deep' error in 
will_paginate. I'm not sure what's causing that.

Thanks,
Scott

> ---
>  src/spec/models/hardware_profile_spec.rb |  138 
> ++++++++++++++++++++++++++++++
>  1 files changed, 138 insertions(+), 0 deletions(-)
>  create mode 100644 src/spec/models/hardware_profile_spec.rb
>
> diff --git a/src/spec/models/hardware_profile_spec.rb 
> b/src/spec/models/hardware_profile_spec.rb
> new file mode 100644
> index 0000000..8f62be2
> --- /dev/null
> +++ b/src/spec/models/hardware_profile_spec.rb
> @@ -0,0 +1,138 @@
> +require 'spec_helper'
> +
> +describe HardwareProfile do
> +  before(:each) do
> +    @valid_attributes = Factory.attributes_for(:mock_hwp1)
> +  end
> +
> +  it "should create a new hardware profile" do
> +    hp = HardwareProfile.new(@valid_attributes)
> +    hp.should be_valid
> +  end
> +
> +  it "should not validate for missing name" do
> +    hp = HardwareProfile.new(@valid_attributes)
> +
> +    [nil, ""].each do |value|
> +      hp.name = value
> +      hp.should_not be_valid
> +    end
> +  end
> +
> +  it "should require unique names" do
> +    hp1 = Factory.create(:mock_hwp1)
> +    hp2 = Factory.create(:mock_hwp2)
> +    hp1.should be_valid
> +    hp2.should be_valid
> +
> +    hp2.name = hp1.name
> +    hp2.should_not be_valid
> +  end
> +
> +  it "should require valid amount of memory" do
> +    hp = HardwareProfile.new(@valid_attributes)
> +
> +    [nil, "hello", -1].each do |fail_value|
> +      hp.memory = fail_value
> +      hp.should_not be_valid
> +    end
> +  end
> +
> +  it "should require valid amount of storage" do
> +    hp = HardwareProfile.new(@valid_attributes)
> +
> +    [nil, "hello", -1].each do |fail_value|
> +      hp.storage = fail_value
> +      hp.should_not be_valid
> +    end
> +  end
> +
> +  it "should not require architecture when there's no provider" do
> +    hp = HardwareProfile.new(@valid_attributes)
> +    hp.architecture = nil
> +    hp.should be_valid
> +  end
> +
> +  it "should require architecture when it's with provider" do
> +    #provider = Factory.build(:mock_provider)
> +    hp = HardwareProfile.new(@valid_attributes)
> +    hp.provider = Provider.new
> +
> +    hp.should be_valid
> +    hp.architecture = nil
> +    hp.should_not be_valid
> +  end
> +
> +  it "should reject Aggregator profiles for custom Instance profiles" do
> +    hp = HardwareProfile.new(@valid_attributes)
> +    hp.aggregator_hardware_profiles << hp
> +    hp.should_not be_valid
> +    hp.should have(1).error_on(:aggregator_hardware_profiles)
> +    hp.errors.on(:aggregator_hardware_profiles).should eql(
> +      "Aggregator profiles are not allowed for custom Instance profiles")
> +
> +    hp.aggregator_hardware_profiles.clear
> +    hp.should be_valid
> + end
> +
> +  it "should reject Provider profiles for custom Instance profiles" do
> +    hp = HardwareProfile.new(@valid_attributes)
> +    hp.provider_hardware_profiles << hp
> +    hp.should_not be_valid
> +    hp.should have(1).error_on(:provider_hardware_profiles)
> +    hp.errors.on(:provider_hardware_profiles).should eql(
> +      "Provider profiles are not allowed for custom Instance profiles")
> +
> +    hp.provider_hardware_profiles.clear
> +    hp.should be_valid
> +  end
> +
> +  it "should require either provider or pool to be blank" do
> +    hp = HardwareProfile.new(@valid_attributes)
> +    hp.provider = Provider.new
> +    hp.portal_pool = PortalPool.new
> +    hp.should_not be_valid
> +    hp.should have(1).error_on(:provider)
> +    hp.errors.on(:provider).should eql(
> +      "provider or pool must be blank")
> +    hp.should have(1).error_on(:portal_pool)
> +    hp.errors.on(:portal_pool).should eql(
> +      "provider or pool must be blank")
> +
> +    hp.provider = nil
> +    hp.should be_valid
> +
> +    hp.provider = Provider.new
> +    hp.portal_pool = nil
> +    hp.should be_valid
> +  end
> +
> +  it "should allow Provider profiles only for provider profiles" do
> +    hp = HardwareProfile.new(@valid_attributes)
> +    hp.provider = nil
> +    hp.portal_pool = PortalPool.new
> +
> +    hp.provider_hardware_profiles << hp
> +    hp.should have(1).error_on(:provider_hardware_profiles)
> +    hp.errors.on(:provider_hardware_profiles).should eql(
> +      "Provider profiles only allowed for provider profiles")
> +
> +    hp.provider_hardware_profiles.clear
> +    hp.should be_valid
> +  end
> +
> +  it "should allow Aggregator profiles only for pool profiles" do
> +    hp = HardwareProfile.new(@valid_attributes)
> +    hp.provider = Provider.new
> +    hp.portal_pool = nil
> +
> +    hp.aggregator_hardware_profiles << hp
> +    hp.should have(1).error_on(:aggregator_hardware_profiles)
> +    hp.errors.on(:aggregator_hardware_profiles).should eql(
> +      "Aggregator profiles only allowed for pool profiles")
> +
> +    hp.aggregator_hardware_profiles.clear
> +    hp.should be_valid
> +  end
> +
> +end
>   

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to