Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
6edc8d50
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 搜索 >>
提交
6edc8d50
编写于
2月 01, 2017
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add feature specs
上级
3dfb6a30
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
147 addition
and
39 deletion
+147
-39
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+2
-2
app/controllers/projects/compare_controller.rb
app/controllers/projects/compare_controller.rb
+2
-2
app/models/repository.rb
app/models/repository.rb
+3
-1
spec/features/projects/blobs/view_on_env_spec.rb
spec/features/projects/blobs/view_on_env_spec.rb
+0
-7
spec/features/projects/commit/view_on_env_spec.rb
spec/features/projects/commit/view_on_env_spec.rb
+0
-9
spec/features/projects/compare/view_on_env_spec.rb
spec/features/projects/compare/view_on_env_spec.rb
+0
-9
spec/features/projects/merge_requests/view_on_env_spec.rb
spec/features/projects/merge_requests/view_on_env_spec.rb
+0
-9
spec/features/projects/view_on_env_spec.rb
spec/features/projects/view_on_env_spec.rb
+140
-0
未找到文件。
app/controllers/projects/blob_controller.rb
浏览文件 @
6edc8d50
...
@@ -30,8 +30,8 @@ class Projects::BlobController < Projects::ApplicationController
...
@@ -30,8 +30,8 @@ class Projects::BlobController < Projects::ApplicationController
end
end
def
show
def
show
branch_name
=
@ref
if
@repository
.
branch_exists?
(
@ref
)
environment_args
=
@repository
.
branch_exists?
(
@ref
)
?
{
ref:
@ref
}
:
{
commit:
@commit
}
@environment
=
@project
.
environments_for
(
commit:
@commit
,
ref:
branch_name
).
last
@environment
=
@project
.
environments_for
(
**
environment_args
).
last
@environment
=
nil
unless
can?
(
current_user
,
:read_environment
,
@environment
)
@environment
=
nil
unless
can?
(
current_user
,
:read_environment
,
@environment
)
end
end
...
...
app/controllers/projects/compare_controller.rb
浏览文件 @
6edc8d50
...
@@ -57,8 +57,8 @@ class Projects::CompareController < Projects::ApplicationController
...
@@ -57,8 +57,8 @@ class Projects::CompareController < Projects::ApplicationController
@diffs
=
@compare
.
diffs
(
diff_options
)
@diffs
=
@compare
.
diffs
(
diff_options
)
branch_name
=
@head_ref
if
@repository
.
branch_exists?
(
@head_ref
)
environment_args
=
@repository
.
branch_exists?
(
@head_ref
)
?
{
ref:
@head_ref
}
:
{
commit:
@commit
}
@environment
=
@project
.
environments_for
(
commit:
@commit
,
ref:
branch_name
).
last
@environment
=
@project
.
environments_for
(
**
environment_args
).
last
@environment
=
nil
unless
can?
(
current_user
,
:read_environment
,
@environment
)
@environment
=
nil
unless
can?
(
current_user
,
:read_environment
,
@environment
)
@diff_notes_disabled
=
true
@diff_notes_disabled
=
true
...
...
app/models/repository.rb
浏览文件 @
6edc8d50
...
@@ -467,6 +467,8 @@ class Repository
...
@@ -467,6 +467,8 @@ class Repository
unless
Gitlab
::
Git
.
blank_ref?
(
sha
)
unless
Gitlab
::
Git
.
blank_ref?
(
sha
)
Blob
.
decorate
(
Gitlab
::
Git
::
Blob
.
find
(
self
,
sha
,
path
))
Blob
.
decorate
(
Gitlab
::
Git
::
Blob
.
find
(
self
,
sha
,
path
))
end
end
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
nil
end
end
def
blob_by_oid
(
oid
)
def
blob_by_oid
(
oid
)
...
@@ -1190,7 +1192,7 @@ class Repository
...
@@ -1190,7 +1192,7 @@ class Repository
def
route_map_for
(
sha
)
def
route_map_for
(
sha
)
blob
=
blob_at
(
sha
,
ROUTE_MAP_PATH
)
blob
=
blob_at
(
sha
,
ROUTE_MAP_PATH
)
return
unless
blob
return
unless
blob
blob
.
load_all_data!
(
self
)
blob
.
load_all_data!
(
self
)
blob
.
data
blob
.
data
end
end
...
...
spec/features/projects/blobs/view_on_env_spec.rb
已删除
100644 → 0
浏览文件 @
3dfb6a30
require
'spec_helper'
feature
'Blob'
do
describe
'View on environment'
do
# TODO: Test
end
end
spec/features/projects/commit/view_on_env_spec.rb
已删除
100644 → 0
浏览文件 @
3dfb6a30
require
'spec_helper'
feature
'Commit'
do
describe
'Diff'
do
describe
'View on environment'
do
# TODO: Test
end
end
end
spec/features/projects/compare/view_on_env_spec.rb
已删除
100644 → 0
浏览文件 @
3dfb6a30
require
'spec_helper'
feature
'Compare'
do
describe
'Diff'
do
describe
'View on environment'
do
# TODO: Test
end
end
end
spec/features/projects/merge_requests/view_on_env_spec.rb
已删除
100644 → 0
浏览文件 @
3dfb6a30
require
'spec_helper'
feature
'Merge Request'
do
describe
'Diff'
do
describe
'View on environment'
do
# TODO: Test
end
end
end
spec/features/projects/view_on_env_spec.rb
0 → 100644
浏览文件 @
6edc8d50
require
'spec_helper'
describe
'View on environment'
,
js:
true
do
include
WaitForAjax
let
(
:branch_name
)
{
'feature'
}
let
(
:file_path
)
{
'files/ruby/feature.rb'
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
project
.
creator
}
before
do
project
.
team
<<
[
user
,
:master
]
end
context
'when the branch has a route map'
do
let
(
:route_map
)
do
<<-
MAP
.
strip_heredoc
- source: /files/(.*)
\\
..*/
public: '
\\
1'
MAP
end
before
do
Files
::
CreateService
.
new
(
project
,
user
,
source_branch:
branch_name
,
target_branch:
branch_name
,
commit_message:
"Add .gitlab/route-map.yml"
,
file_path:
'.gitlab/route-map.yml'
,
file_content:
route_map
).
execute
# Update the file so that we still have a commit that will have a file on the environment
Files
::
UpdateService
.
new
(
project
,
user
,
source_branch:
branch_name
,
target_branch:
branch_name
,
commit_message:
"Update feature"
,
file_path:
file_path
,
file_content:
"# Noop"
).
execute
end
context
'and an active deployment'
do
let
(
:sha
)
{
project
.
commit
(
branch_name
).
sha
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
,
name:
'review/feature'
,
external_url:
'http://feature.review.example.com'
)
}
let!
(
:deployment
)
{
create
(
:deployment
,
environment:
environment
,
ref:
branch_name
,
sha:
sha
)
}
context
'when visiting the diff of a merge request for the branch'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
:simple
,
source_project:
project
,
source_branch:
branch_name
)
}
before
do
login_as
(
user
)
visit
diffs_namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
wait_for_ajax
end
it
'has a "View on env" button'
do
within
'.diffs'
do
expect
(
page
).
to
have_link
(
'View on feature.review.example.com'
,
href:
'http://feature.review.example.com/ruby/feature'
)
end
end
end
context
'when visiting a comparison for the branch'
do
before
do
login_as
(
user
)
visit
namespace_project_compare_path
(
project
.
namespace
,
project
,
from:
'master'
,
to:
branch_name
)
wait_for_ajax
end
it
'has a "View on env" button'
do
expect
(
page
).
to
have_link
(
'View on feature.review.example.com'
,
href:
'http://feature.review.example.com/ruby/feature'
)
end
end
context
'when visiting a comparison for the commit'
do
before
do
login_as
(
user
)
visit
namespace_project_compare_path
(
project
.
namespace
,
project
,
from:
'master'
,
to:
sha
)
wait_for_ajax
end
it
'has a "View on env" button'
do
expect
(
page
).
to
have_link
(
'View on feature.review.example.com'
,
href:
'http://feature.review.example.com/ruby/feature'
)
end
end
context
'when visiting a blob on the branch'
do
before
do
login_as
(
user
)
visit
namespace_project_blob_path
(
project
.
namespace
,
project
,
File
.
join
(
branch_name
,
file_path
))
wait_for_ajax
end
it
'has a "View on env" button'
do
expect
(
page
).
to
have_link
(
'View on feature.review.example.com'
,
href:
'http://feature.review.example.com/ruby/feature'
)
end
end
context
'when visiting a blob on the commit'
do
before
do
login_as
(
user
)
visit
namespace_project_blob_path
(
project
.
namespace
,
project
,
File
.
join
(
sha
,
file_path
))
wait_for_ajax
end
it
'has a "View on env" button'
do
expect
(
page
).
to
have_link
(
'View on feature.review.example.com'
,
href:
'http://feature.review.example.com/ruby/feature'
)
end
end
context
'when visiting the commit'
do
before
do
login_as
(
user
)
visit
namespace_project_commit_path
(
project
.
namespace
,
project
,
sha
)
wait_for_ajax
end
it
'has a "View on env" button'
do
expect
(
page
).
to
have_link
(
'View on feature.review.example.com'
,
href:
'http://feature.review.example.com/ruby/feature'
)
end
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录