Sha256: 7e86cff70850dcdf24a28cd79d0e32e80886a65681340b8665798b575f674324

Contents?: true

Size: 1.84 KB

Versions: 4

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
            expect(client).not_to receive(:owning_organization)
            expect(client).to 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

4 entries across 4 versions & 1 rubygems

Version Path
new_cfoundry-4.9.1 spec/cfoundry/v2/domain_spec.rb
new_cfoundry-4.9.0 spec/cfoundry/v2/domain_spec.rb
new_cfoundry-4.8.3 spec/cfoundry/v2/domain_spec.rb
new_cfoundry-4.8.2 spec/cfoundry/v2/domain_spec.rb