Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
35487a1e
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
35487a1e
编写于
1月 25, 2020
作者:
G
GitLab Bot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add latest changes from gitlab-org/gitlab@master
上级
4f749a9b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
72 addition
and
6 deletion
+72
-6
app/models/serverless/domain_cluster.rb
app/models/serverless/domain_cluster.rb
+7
-2
lib/gitlab/prometheus/queries/knative_invocation_query.rb
lib/gitlab/prometheus/queries/knative_invocation_query.rb
+1
-1
lib/gitlab/serverless/domain.rb
lib/gitlab/serverless/domain.rb
+13
-0
spec/factories/serverless/domain_cluster.rb
spec/factories/serverless/domain_cluster.rb
+0
-1
spec/lib/gitlab/serverless/domain_spec.rb
spec/lib/gitlab/serverless/domain_spec.rb
+22
-0
spec/models/serverless/domain_cluster_spec.rb
spec/models/serverless/domain_cluster_spec.rb
+29
-2
未找到文件。
app/models/serverless/domain_cluster.rb
浏览文件 @
35487a1e
...
...
@@ -4,11 +4,16 @@ module Serverless
class
DomainCluster
<
ApplicationRecord
self
.
table_name
=
'serverless_domain_cluster'
HEX_REGEXP
=
%r{
\A\h
+
\z
}
.
freeze
belongs_to
:pages_domain
belongs_to
:knative
,
class_name:
'Clusters::Applications::Knative'
,
foreign_key:
'clusters_applications_knative_id'
belongs_to
:creator
,
class_name:
'User'
,
optional:
true
validates
:pages_domain
,
:knative
,
:uuid
,
presence:
true
validates
:uuid
,
uniqueness:
true
,
length:
{
is:
14
}
validates
:pages_domain
,
:knative
,
presence:
true
validates
:uuid
,
presence:
true
,
uniqueness:
true
,
length:
{
is:
Gitlab
::
Serverless
::
Domain
::
UUID_LENGTH
},
format:
{
with:
HEX_REGEXP
,
message:
'only allows hex characters'
}
default_value_for
(
:uuid
,
allows_nil:
false
)
{
Gitlab
::
Serverless
::
Domain
.
generate_uuid
}
end
end
lib/gitlab/prometheus/queries/knative_invocation_query.rb
浏览文件 @
35487a1e
...
...
@@ -20,7 +20,7 @@ module Gitlab
protected
def
context
(
function_id
)
function
=
Serverless
::
Function
.
find_by_id
(
function_id
)
function
=
::
Serverless
::
Function
.
find_by_id
(
function_id
)
{
function_name:
function
.
name
,
kube_namespace:
function
.
namespace
...
...
lib/gitlab/serverless/domain.rb
0 → 100644
浏览文件 @
35487a1e
# frozen_string_literal: true
module
Gitlab
module
Serverless
class
Domain
UUID_LENGTH
=
14
def
self
.
generate_uuid
SecureRandom
.
hex
(
UUID_LENGTH
/
2
)
end
end
end
end
spec/factories/serverless/domain_cluster.rb
浏览文件 @
35487a1e
...
...
@@ -5,6 +5,5 @@ FactoryBot.define do
pages_domain
{
create
(
:pages_domain
)
}
knative
{
create
(
:clusters_applications_knative
)
}
creator
{
create
(
:user
)
}
uuid
{
SecureRandom
.
hex
(
7
)
}
end
end
spec/lib/gitlab/serverless/domain_spec.rb
0 → 100644
浏览文件 @
35487a1e
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
Serverless
::
Domain
do
describe
'.generate_uuid'
do
it
'has 14 characters'
do
expect
(
described_class
.
generate_uuid
.
length
).
to
eq
(
described_class
::
UUID_LENGTH
)
end
it
'consists of only hexadecimal characters'
do
expect
(
described_class
.
generate_uuid
).
to
match
(
/\A\h+\z/
)
end
it
'uses random characters'
do
uuid
=
'abcd1234567890'
expect
(
SecureRandom
).
to
receive
(
:hex
).
with
(
described_class
::
UUID_LENGTH
/
2
).
and_return
(
uuid
)
expect
(
described_class
.
generate_uuid
).
to
eq
(
uuid
)
end
end
end
spec/models/serverless/domain_cluster_spec.rb
浏览文件 @
35487a1e
...
...
@@ -8,10 +8,17 @@ describe Serverless::DomainCluster do
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:pages_domain
)
}
it
{
is_expected
.
to
validate_presence_of
(
:knative
)
}
it
{
is_expected
.
to
validate_presence_of
(
:uuid
)
}
it
{
is_expected
.
to
validate_presence_of
(
:uuid
)
}
it
{
is_expected
.
to
validate_length_of
(
:uuid
).
is_equal_to
(
Gitlab
::
Serverless
::
Domain
::
UUID_LENGTH
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:uuid
)
}
it
{
is_expected
.
to
validate_length_of
(
:uuid
).
is_equal_to
(
14
)
}
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
end
describe
'associations'
do
...
...
@@ -19,4 +26,24 @@ describe Serverless::DomainCluster do
it
{
is_expected
.
to
belong_to
(
:knative
)
}
it
{
is_expected
.
to
belong_to
(
:creator
).
optional
}
end
describe
'uuid'
do
context
'when nil'
do
it
'generates a value by default'
do
attributes
=
build
(
:serverless_domain_cluster
).
attributes
.
merge
(
uuid:
nil
)
expect
(
Gitlab
::
Serverless
::
Domain
).
to
receive
(
:generate_uuid
).
and_call_original
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
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录