Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
4eb24c31
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,发现更多精彩内容 >>
提交
4eb24c31
编写于
3月 15, 2017
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Verify config/mail_room.yml is interpretable Ruby
上级
b7166806
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
27 deletion
+40
-27
lib/gitlab/redis.rb
lib/gitlab/redis.rb
+5
-2
spec/config/mail_room_spec.rb
spec/config/mail_room_spec.rb
+35
-25
未找到文件。
lib/gitlab/redis.rb
浏览文件 @
4eb24c31
...
...
@@ -9,7 +9,6 @@ module Gitlab
SIDEKIQ_NAMESPACE
=
'resque:gitlab'
.
freeze
MAILROOM_NAMESPACE
=
'mail_room:gitlab'
.
freeze
DEFAULT_REDIS_URL
=
'redis://localhost:6379'
.
freeze
CONFIG_FILE
=
File
.
expand_path
(
'../../config/resque.yml'
,
__dir__
)
class
<<
self
delegate
:params
,
:url
,
to: :new
...
...
@@ -33,13 +32,17 @@ module Gitlab
return
@_raw_config
if
defined?
(
@_raw_config
)
begin
@_raw_config
=
ERB
.
new
(
File
.
read
(
CONFIG_FILE
)).
result
.
freeze
@_raw_config
=
ERB
.
new
(
File
.
read
(
config_file
)).
result
.
freeze
rescue
Errno
::
ENOENT
@_raw_config
=
false
end
@_raw_config
end
def
config_file
ENV
[
'GITLAB_REDIS_CONFIG_FILE'
]
||
File
.
expand_path
(
'../../config/resque.yml'
,
__dir__
)
end
end
def
initialize
(
rails_env
=
nil
)
...
...
spec/config/mail_room_spec.rb
浏览文件 @
4eb24c31
require
'spec_helper'
describe
'mail_room.yml'
do
let
(
:config_path
)
{
'config/mail_room.yml'
}
let
(
:configuration
)
{
YAML
.
load
(
ERB
.
new
(
File
.
read
(
config_path
)).
result
)
}
before
(
:each
)
{
clear_raw_config
}
after
(
:each
)
{
clear_raw_config
}
let
(
:mailroom_config_path
)
{
'config/mail_room.yml'
}
let
(
:gitlab_config_path
)
{
'config/mail_room.yml'
}
let
(
:redis_config_path
)
{
'config/resque.yml'
}
context
'when incoming email is disabled'
do
before
do
ENV
[
'MAIL_ROOM_GITLAB_CONFIG_FILE'
]
=
Rails
.
root
.
join
(
'spec/fixtures/config/mail_room_disabled.yml'
).
to_s
Gitlab
::
MailRoom
.
reset_config!
end
let
(
:configuration
)
do
vars
=
{
'MAIL_ROOM_GITLAB_CONFIG_FILE'
=>
absolute_path
(
gitlab_config_path
),
'GITLAB_REDIS_CONFIG_FILE'
=>
absolute_path
(
redis_config_path
)
}
cmd
=
"puts ERB.new(File.read(
#{
absolute_path
(
mailroom_config_path
).
inspect
}
)).result"
after
do
ENV
[
'MAIL_ROOM_GITLAB_CONFIG_FILE'
]
=
nil
end
output
,
status
=
Gitlab
::
Popen
.
popen
(
%W(ruby -rerb -e
#{
cmd
}
)
,
absolute_path
(
'config'
),
vars
)
raise
"Error interpreting
#{
mailroom_config_path
}
:
#{
output
}
"
unless
status
.
zero?
YAML
.
load
(
output
)
end
before
(
:each
)
do
ENV
[
'GITLAB_REDIS_CONFIG_FILE'
]
=
absolute_path
(
redis_config_path
)
clear_redis_raw_config
end
after
(
:each
)
do
ENV
[
'GITLAB_REDIS_CONFIG_FILE'
]
=
nil
clear_redis_raw_config
end
context
'when incoming email is disabled'
do
let
(
:gitlab_config_path
)
{
'spec/fixtures/config/mail_room_disabled.yml'
}
it
'contains no configuration'
do
expect
(
configuration
[
:mailboxes
]).
to
be_nil
...
...
@@ -22,21 +37,12 @@ describe 'mail_room.yml' do
end
context
'when incoming email is enabled'
do
let
(
:
redis_config
)
{
Rails
.
root
.
join
(
'spec/fixtures/config/redis_new_format_host.yml'
)
}
let
(
:
gitlab_redis
)
{
Gitlab
::
Redis
.
new
(
Rails
.
env
)
}
let
(
:
gitlab_config_path
)
{
'spec/fixtures/config/mail_room_enabled.yml'
}
let
(
:
redis_config_path
)
{
'spec/fixtures/config/redis_new_format_host.yml'
}
before
do
ENV
[
'MAIL_ROOM_GITLAB_CONFIG_FILE'
]
=
Rails
.
root
.
join
(
'spec/fixtures/config/mail_room_enabled.yml'
).
to_s
Gitlab
::
MailRoom
.
reset_config!
end
after
do
ENV
[
'MAIL_ROOM_GITLAB_CONFIG_FILE'
]
=
nil
end
let
(
:gitlab_redis
)
{
Gitlab
::
Redis
.
new
(
Rails
.
env
)
}
it
'contains the intended configuration'
do
stub_const
(
'Gitlab::Redis::CONFIG_FILE'
,
redis_config
)
expect
(
configuration
[
:mailboxes
].
length
).
to
eq
(
1
)
mailbox
=
configuration
[
:mailboxes
].
first
...
...
@@ -66,9 +72,13 @@ describe 'mail_room.yml' do
end
end
def
clear_raw_config
def
clear_r
edis_r
aw_config
Gitlab
::
Redis
.
remove_instance_variable
(
:@_raw_config
)
rescue
NameError
# raised if @_raw_config was not set; ignore
end
def
absolute_path
(
path
)
Rails
.
root
.
join
(
path
).
to_s
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录