Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
GitLab
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
需求
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
测试用例
产物
部署
发布
Package registry
Container registry
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
洞察
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
gitlab-cn
GitLab
提交
0b6bf9a1
提交
0b6bf9a1
编辑于
1 year ago
作者:
Jonas Larsen
提交者:
Sashi Kumar Kumaresan
1 year ago
浏览文件
操作
下载
补丁
差异文件
Fix StandardContext test
上级
6880e362
No related branches found
No related tags found
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
ee/spec/lib/gitlab/tracking/standard_context_spec.rb
+0
-31
0 个添加, 31 个删除
ee/spec/lib/gitlab/tracking/standard_context_spec.rb
spec/lib/gitlab/tracking/standard_context_spec.rb
+19
-29
19 个添加, 29 个删除
spec/lib/gitlab/tracking/standard_context_spec.rb
有
19 个添加
和
60 个删除
ee/spec/lib/gitlab/tracking/standard_context_spec.rb
已删除
100644 → 0
+
0
−
31
浏览文件 @
6880e362
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Tracking
::
StandardContext
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:namespace
)
{
create
(
:namespace
)
}
let_it_be
(
:plan
)
{
:ultimate_plan
}
let
(
:snowplow_context
)
{
subject
.
to_context
}
describe
'#to_context'
do
context
'plan'
do
context
'when namespace is not available'
do
it
'is nil'
do
expect
(
snowplow_context
.
to_json
.
dig
(
:data
,
:plan
)).
to
be_nil
end
end
context
'when namespace is available'
,
:saas
do
let
(
:namespace
)
{
create
(
:namespace_with_plan
,
plan:
plan
)
}
subject
{
described_class
.
new
(
namespace_id:
namespace
.
id
,
plan_name:
namespace
.
actual_plan_name
)
}
it
'contains plan name'
do
expect
(
snowplow_context
.
to_json
.
dig
(
:data
,
:plan
)).
to
eq
(
Plan
::
ULTIMATE
)
end
end
end
end
end
此差异已折叠。
点击以展开。
spec/lib/gitlab/tracking/standard_context_spec.rb
+
19
−
29
浏览文件 @
0b6bf9a1
...
@@ -3,10 +3,6 @@
...
@@ -3,10 +3,6 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Tracking
::
StandardContext
do
RSpec
.
describe
Gitlab
::
Tracking
::
StandardContext
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:namespace
)
{
create
(
:namespace
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:snowplow_context
)
{
subject
.
to_context
}
let
(
:snowplow_context
)
{
subject
.
to_context
}
describe
'#to_context'
do
describe
'#to_context'
do
...
@@ -62,21 +58,27 @@
...
@@ -62,21 +58,27 @@
expect
(
snowplow_context
.
to_json
.
dig
(
:data
,
:context_generated_at
)).
to
eq
(
Time
.
current
)
expect
(
snowplow_context
.
to_json
.
dig
(
:data
,
:context_generated_at
)).
to
eq
(
Time
.
current
)
end
end
context
'plan'
do
it
'contains standard properties'
do
context
'when namespace is not available'
do
standard_properties
=
[
:user_id
,
:project_id
,
:namespace_id
,
:plan
]
it
'is nil'
do
expect
(
snowplow_context
.
to_json
[
:data
].
keys
).
to
include
(
*
standard_properties
)
expect
(
snowplow_context
.
to_json
.
dig
(
:data
,
:plan
)).
to
be_nil
end
end
end
context
'when namespace is available'
do
context
'with standard properties'
do
let
(
:namespace
)
{
create
(
:namespace
)
}
let
(
:user_id
)
{
1
}
let
(
:project_id
)
{
2
}
let
(
:namespace_id
)
{
3
}
let
(
:plan_name
)
{
"plan name"
}
subject
{
described_class
.
new
(
namespace_id:
namespace
.
id
,
plan_name:
namespace
.
actual_plan_name
)
}
subject
do
described_class
.
new
(
user_id:
user_id
,
project_id:
project_id
,
namespace_id:
namespace_id
,
plan_name:
plan_name
)
end
it
'contains plan name'
do
it
'holds the correct values'
,
:aggregate_failures
do
expect
(
snowplow_context
.
to_json
.
dig
(
:data
,
:plan
)).
to
eq
(
Plan
::
DEFAULT
)
json_data
=
snowplow_context
.
to_json
.
fetch
(
:data
)
end
expect
(
json_data
[
:user_id
]).
to
eq
(
user_id
)
expect
(
json_data
[
:project_id
]).
to
eq
(
project_id
)
expect
(
json_data
[
:namespace_id
]).
to
eq
(
namespace_id
)
expect
(
json_data
[
:plan
]).
to
eq
(
plan_name
)
end
end
end
end
...
@@ -95,24 +97,12 @@
...
@@ -95,24 +97,12 @@
end
end
context
'with incorrect argument type'
do
context
'with incorrect argument type'
do
subject
{
described_class
.
new
(
project_id:
create
(
:group
)
)
}
subject
{
described_class
.
new
(
project_id:
"a string"
)
}
it
'does call `track_and_raise_for_dev_exception`'
do
it
'does call `track_and_raise_for_dev_exception`'
do
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:track_and_raise_for_dev_exception
)
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:track_and_raise_for_dev_exception
)
snowplow_context
snowplow_context
end
end
end
end
it
'contains user id'
do
expect
(
snowplow_context
.
to_json
[
:data
].
keys
).
to
include
(
:user_id
)
end
it
'contains namespace and project ids'
do
expect
(
snowplow_context
.
to_json
[
:data
].
keys
).
to
include
(
:project_id
,
:namespace_id
)
end
it
'accepts just project id as integer'
do
expect
{
described_class
.
new
(
project:
1
).
to_context
}.
not_to
raise_error
end
end
end
end
end
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录