Sha256: 06943b371d7f790d96cf022f2d6ca16de986ae31597ff0d7eea1611eee3958a3

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 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 "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

1 entries across 1 versions & 1 rubygems

Version Path
cfoundry-2.3.0 spec/cfoundry/v2/domain_spec.rb