diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-01-22 20:45:45 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-01-22 20:45:45 +0000 |
commit | b39028fb0013a8fe2dafe8486a2b01bd068c1c9c (patch) | |
tree | 4b1f5fb80a3ecd10a0278cc57d5e4e9a65096fb4 /spec | |
parent | ae2166188d11c6a0fef133af4b154ddf7fa83fd6 (diff) | |
parent | cfe65a0d3ef23987fbdf21d3a907b1d2980c1f93 (diff) | |
download | gitlab-ce-b39028fb0013a8fe2dafe8486a2b01bd068c1c9c.tar.gz |
Merge branch '52363-add-domain-to-cluster-model' into 'master'
Add domain field into Clusters::Cluster
See merge request gitlab-org/gitlab-ce!24368
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/clusters/clusters.rb | 4 | ||||
-rw-r--r-- | spec/models/clusters/cluster_spec.rb | 27 |
2 files changed, 30 insertions, 1 deletions
diff --git a/spec/factories/clusters/clusters.rb b/spec/factories/clusters/clusters.rb index 3e2c0df8afb..a2e5f4862db 100644 --- a/spec/factories/clusters/clusters.rb +++ b/spec/factories/clusters/clusters.rb @@ -59,5 +59,9 @@ FactoryBot.define do trait :with_installed_helm do application_helm factory: %i(clusters_applications_helm installed) end + + trait :with_domain do + domain 'example.com' + end end end diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb index f447e64b029..0161db740ee 100644 --- a/spec/models/clusters/cluster_spec.rb +++ b/spec/models/clusters/cluster_spec.rb @@ -113,7 +113,7 @@ describe Clusters::Cluster do end end - describe 'validation' do + describe 'validations' do subject { cluster.valid? } context 'when validates name' do @@ -252,6 +252,31 @@ describe Clusters::Cluster do end end end + + describe 'domain validation' do + let(:cluster) { build(:cluster) } + + subject { cluster } + + context 'when cluster has domain' do + let(:cluster) { build(:cluster, :with_domain) } + + it { is_expected.to be_valid } + end + + context 'when cluster has an invalid domain' do + let(:cluster) { build(:cluster, domain: 'not-valid-domain') } + + it 'should add an error on domain' do + expect(subject).not_to be_valid + expect(subject.errors[:domain].first).to eq('is not a fully qualified domain name') + end + end + + context 'when cluster does not have a domain' do + it { is_expected.to be_valid } + end + end end describe '.ancestor_clusters_for_clusterable' do |