Sha256: 704377f431c13359bef14010eeb31870fdd6b3f735ecacb58b7907a216817f9d

Contents?: true

Size: 1.84 KB

Versions: 54

Compression:

Stored size: 1.84 KB

Contents

require "spec_helper"

module CFoundry
  module V2
    describe Domain do
      let(:space) { build(:space) }
      let(:domain) { build(:domain, :spaces => [space]) }

      it "should have a spaces association" do
        expect(domain.spaces).to eq([space])
      end

      describe "#owning_organization" do
        context "when the domain is not persisted" do
          let(:client) { build(:client) }
          let(:domain) { build(:domain, client: client, guid: nil)}
          it "asdf" do
            client.should_not_receive(:owning_organization)
            client.should_receive(:organization)
            domain.owning_organization
          end
        end
      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

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
cfoundry-4.7.2.rc1 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.7.1 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.7.1.rc1 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.7.0 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.6.3.rc3 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.6.3.rc2 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.6.3.rc1 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.6.2 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.6.1 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.6.0 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.5.3 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.5.2 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.5.1 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.5.0 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.3.12 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.3.11 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.3.10 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.3.9 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.3.8 spec/cfoundry/v2/domain_spec.rb
cfoundry-4.3.7 spec/cfoundry/v2/domain_spec.rb