spec/cfoundry/v2/domain_spec.rb in cfoundry-2.2.0rc3 vs spec/cfoundry/v2/domain_spec.rb in cfoundry-2.3.0

- old
+ new

@@ -7,8 +7,45 @@ let(:domain) { build(:domain, :spaces => [space]) } it "should have a spaces association" do expect(domain.spaces).to eq([space]) end + + describe "validations" do + subject { build(:domain) } + it { should validate_presence_of(:name) } + it { should allow_value("run.pivotal.io").for(:name) } + it { should_not allow_value("not-a-url").for(:name) } + it { should validate_presence_of(:owning_organization) } + end + + describe "#system?" do + let(:params) { {} } + let(:domain) { build(:domain, {:owning_organization => nil, client: client}.merge(params)) } + let(:client) { build(:client) } + + context "when the domain is persisted and has no owning organization" do + it "returns true" do + expect(domain.system?).to be_true + end + end + + context "when the domain is not persisted" do + let(:params) { {:guid => nil} } + + it "returns false" do + expect(domain.system?).to be_false + end + end + + context "when the domain has an owning org" do + let(:params) { {:owning_organization => org} } + let(:org) { build(:organization) } + + it "returns false" do + expect(domain.system?).to be_false + end + end + end end end end