Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
7d2fbe6b
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 搜索 >>
提交
7d2fbe6b
编写于
3月 24, 2013
作者:
A
Andrew8xx8
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Project Snippets now part of project
上级
61723900
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
106 addition
and
2 deletion
+106
-2
app/controllers/projects/application_controller.rb
app/controllers/projects/application_controller.rb
+2
-1
app/controllers/projects/snippets_controller.rb
app/controllers/projects/snippets_controller.rb
+2
-0
app/helpers/tab_helper.rb
app/helpers/tab_helper.rb
+1
-1
spec/features/projects/snippets_spec.rb
spec/features/projects/snippets_spec.rb
+101
-0
未找到文件。
app/controllers/projects/application_controller.rb
浏览文件 @
7d2fbe6b
class
Projects::ApplicationController
<
ApplicationController
before_filter
:project
before_filter
:repository
end
app/controllers/projects/snippets_controller.rb
浏览文件 @
7d2fbe6b
...
...
@@ -14,6 +14,8 @@ class Projects::SnippetsController < Projects::ApplicationController
# Allow destroy snippet
before_filter
:authorize_admin_snippet!
,
only:
[
:destroy
]
layout
'project_resource'
respond_to
:html
def
index
...
...
app/helpers/tab_helper.rb
浏览文件 @
7d2fbe6b
...
...
@@ -73,7 +73,7 @@ module TabHelper
end
def
project_tab_class
return
"active"
if
current_page?
(
controller:
"projects"
,
action: :edit
,
id:
@project
)
return
"active"
if
current_page?
(
controller:
"
/
projects"
,
action: :edit
,
id:
@project
)
if
[
'services'
,
'hooks'
,
'deploy_keys'
,
'team_members'
].
include?
controller
.
controller_name
"active"
...
...
spec/features/projects/snippets_spec.rb
0 → 100644
浏览文件 @
7d2fbe6b
require
'spec_helper'
describe
"Project::Snippets"
do
let
(
:project
)
{
create
(
:project
)
}
before
do
login_as
:user
project
.
team
<<
[
@user
,
:developer
]
end
describe
"GET /:project/snippets"
do
before
do
@snippet
=
create
(
:snippet
,
author:
@user
,
project:
project
)
visit
project_snippets_path
(
project
)
p
project_snippets_path
(
project
)
end
subject
{
page
}
it
{
should
have_content
(
@snippet
.
title
[
0
..
10
])
}
it
{
should
have_content
(
@snippet
.
project
.
name
)
}
describe
"Destroy"
do
before
do
# admin access to remove snippet
@user
.
users_projects
.
destroy_all
project
.
team
<<
[
@user
,
:master
]
visit
edit_project_snippet_path
(
project
,
@snippet
)
end
it
"should remove entry"
do
expect
{
click_link
"destroy_snippet_
#{
@snippet
.
id
}
"
}.
to
change
{
Snippet
.
count
}.
by
(
-
1
)
end
end
end
describe
"New project snippet"
do
before
do
visit
project_snippets_path
(
project
)
click_link
"New Snippet"
end
it
"should open new snippet popup"
do
page
.
current_path
.
should
==
new_project_snippet_path
(
project
)
end
describe
"fill in"
,
js:
true
do
before
do
fill_in
"snippet_title"
,
with:
"login function"
fill_in
"snippet_file_name"
,
with:
"test.rb"
page
.
execute_script
(
"editor.insert('def login; end');"
)
end
it
{
expect
{
click_button
"Save"
}.
to
change
{
Snippet
.
count
}.
by
(
1
)
}
it
"should add new snippet to table"
do
click_button
"Save"
page
.
current_path
.
should
==
project_snippet_path
(
project
,
Snippet
.
last
)
page
.
should
have_content
"login function"
page
.
should
have_content
"test.rb"
end
end
end
describe
"Edit project snippet"
do
before
do
@snippet
=
create
(
:snippet
,
author:
@user
,
project:
project
)
visit
project_snippet_path
(
project
,
@snippet
)
click_link
"Edit Snippet"
end
it
"should open edit page"
do
page
.
current_path
.
should
==
edit_project_snippet_path
(
project
,
@snippet
)
end
describe
"fill in"
do
before
do
fill_in
"snippet_title"
,
with:
"login function"
fill_in
"snippet_file_name"
,
with:
"test.rb"
end
it
{
expect
{
click_button
"Save"
}.
to_not
change
{
Snippet
.
count
}
}
it
"should update snippet fields"
do
click_button
"Save"
page
.
current_path
.
should
==
project_snippet_path
(
project
,
@snippet
)
page
.
should
have_content
"login function"
page
.
should
have_content
"test.rb"
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录