2019-12-14 10:07:56 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe ::Serverless::DomainCluster do
|
2019-12-14 10:07:56 -05:00
|
|
|
subject { create(:serverless_domain_cluster) }
|
|
|
|
|
|
|
|
describe 'validations' do
|
|
|
|
it { is_expected.to validate_presence_of(:pages_domain) }
|
|
|
|
it { is_expected.to validate_presence_of(:knative) }
|
|
|
|
|
2020-01-25 04:08:46 -05:00
|
|
|
it { is_expected.to validate_presence_of(:uuid) }
|
2020-02-20 10:08:44 -05:00
|
|
|
it { is_expected.to validate_length_of(:uuid).is_equal_to(::Serverless::Domain::UUID_LENGTH) }
|
2019-12-14 10:07:56 -05:00
|
|
|
it { is_expected.to validate_uniqueness_of(:uuid) }
|
2020-01-25 04:08:46 -05:00
|
|
|
|
|
|
|
it 'validates that uuid has only hex characters' do
|
|
|
|
subject = build(:serverless_domain_cluster, uuid: 'z1234567890123')
|
|
|
|
subject.valid?
|
|
|
|
|
|
|
|
expect(subject.errors[:uuid]).to include('only allows hex characters')
|
|
|
|
end
|
2019-12-14 10:07:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'associations' do
|
|
|
|
it { is_expected.to belong_to(:pages_domain) }
|
|
|
|
it { is_expected.to belong_to(:knative) }
|
|
|
|
it { is_expected.to belong_to(:creator).optional }
|
|
|
|
end
|
2020-01-25 04:08:46 -05:00
|
|
|
|
|
|
|
describe 'uuid' do
|
|
|
|
context 'when nil' do
|
|
|
|
it 'generates a value by default' do
|
|
|
|
attributes = build(:serverless_domain_cluster).attributes.merge(uuid: nil)
|
2020-02-20 10:08:44 -05:00
|
|
|
expect(::Serverless::Domain).to receive(:generate_uuid).and_call_original
|
2020-01-25 04:08:46 -05:00
|
|
|
|
|
|
|
subject = Serverless::DomainCluster.new(attributes)
|
|
|
|
|
|
|
|
expect(subject.uuid).not_to be_blank
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when not nil' do
|
|
|
|
it 'does not override the existing value' do
|
|
|
|
uuid = 'abcd1234567890'
|
|
|
|
expect(build(:serverless_domain_cluster, uuid: uuid).uuid).to eq(uuid)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-01-28 10:08:36 -05:00
|
|
|
|
2020-02-20 10:08:44 -05:00
|
|
|
describe 'cluster' do
|
|
|
|
it { is_expected.to respond_to(:cluster) }
|
|
|
|
end
|
|
|
|
|
2020-01-28 10:08:36 -05:00
|
|
|
describe 'domain' do
|
|
|
|
it { is_expected.to respond_to(:domain) }
|
|
|
|
end
|
2020-02-05 04:08:43 -05:00
|
|
|
|
|
|
|
describe 'certificate' do
|
|
|
|
it { is_expected.to respond_to(:certificate) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'key' do
|
|
|
|
it { is_expected.to respond_to(:key) }
|
|
|
|
end
|
2019-12-14 10:07:56 -05:00
|
|
|
end
|