Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
38934777
Commit
38934777
authored
Jan 22, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
1e39bf57
b39028fb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
2 deletions
+42
-2
app/models/clusters/cluster.rb
app/models/clusters/cluster.rb
+2
-1
db/migrate/20190114172110_add_domain_to_cluster.rb
db/migrate/20190114172110_add_domain_to_cluster.rb
+9
-0
db/schema.rb
db/schema.rb
+1
-0
spec/factories/clusters/clusters.rb
spec/factories/clusters/clusters.rb
+4
-0
spec/models/clusters/cluster_spec.rb
spec/models/clusters/cluster_spec.rb
+26
-1
No files found.
app/models/clusters/cluster.rb
View file @
38934777
...
...
@@ -49,8 +49,9 @@ module Clusters
validates
:name
,
cluster_name:
true
validates
:cluster_type
,
presence:
true
validate
:restrict_modification
,
on: :update
validate
s
:domain
,
allow_nil:
true
,
hostname:
{
allow_numeric_hostname:
true
,
require_valid_tld:
true
}
validate
:restrict_modification
,
on: :update
validate
:no_groups
,
unless: :group_type?
validate
:no_projects
,
unless: :project_type?
...
...
db/migrate/20190114172110_add_domain_to_cluster.rb
0 → 100644
View file @
38934777
# frozen_string_literal: true
class
AddDomainToCluster
<
ActiveRecord
::
Migration
[
5.0
]
DOWNTIME
=
false
def
change
add_column
:clusters
,
:domain
,
:string
end
end
db/schema.rb
View file @
38934777
...
...
@@ -824,6 +824,7 @@ ActiveRecord::Schema.define(version: 20190115054216) do
t
.
string
"name"
,
null:
false
t
.
string
"environment_scope"
,
default:
"*"
,
null:
false
t
.
integer
"cluster_type"
,
limit:
2
,
default:
3
,
null:
false
t
.
string
"domain"
t
.
index
[
"enabled"
],
name:
"index_clusters_on_enabled"
,
using: :btree
t
.
index
[
"user_id"
],
name:
"index_clusters_on_user_id"
,
using: :btree
end
...
...
spec/factories/clusters/clusters.rb
View file @
38934777
...
...
@@ -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
spec/models/clusters/cluster_spec.rb
View file @
38934777
...
...
@@ -113,7 +113,7 @@ describe Clusters::Cluster do
end
end
describe
'validation'
do
describe
'validation
s
'
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment