Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
0a31efb5
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 搜索 >>
提交
0a31efb5
编写于
2月 07, 2017
作者:
A
Adam Niedzielski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove query parameters from notes polling endpoint to make caching easier
上级
57c068e1
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
52 addition
and
8 deletion
+52
-8
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+1
-1
app/controllers/projects/notes_controller.rb
app/controllers/projects/notes_controller.rb
+6
-1
app/views/projects/notes/_notes_with_form.html.haml
app/views/projects/notes/_notes_with_form.html.haml
+1
-1
config/routes/project.rb
config/routes/project.rb
+3
-1
spec/controllers/projects/notes_controller_spec.rb
spec/controllers/projects/notes_controller_spec.rb
+27
-0
spec/routing/project_routing_spec.rb
spec/routing/project_routing_spec.rb
+14
-4
未找到文件。
app/assets/javascripts/notes.js
浏览文件 @
0a31efb5
...
...
@@ -198,7 +198,7 @@ require('./task_list');
this
.
refreshing
=
true
;
return
$
.
ajax
({
url
:
this
.
notes_url
,
data
:
"
last_fetched_at=
"
+
this
.
last_fetched_at
,
headers
:
{
"
X-Last-Fetched-At
"
:
this
.
last_fetched_at
}
,
dataType
:
"
json
"
,
success
:
(
function
(
_this
)
{
return
function
(
data
)
{
...
...
app/controllers/projects/notes_controller.rb
浏览文件 @
0a31efb5
...
...
@@ -211,6 +211,11 @@ class Projects::NotesController < Projects::ApplicationController
end
def
find_current_user_notes
@notes
=
NotesFinder
.
new
(
project
,
current_user
,
params
).
execute
.
inc_author
@notes
=
NotesFinder
.
new
(
project
,
current_user
,
params
.
merge
(
last_fetched_at:
last_fetched_at
))
.
execute
.
inc_author
end
def
last_fetched_at
request
.
headers
[
'X-Last-Fetched-At'
]
end
end
app/views/projects/notes/_notes_with_form.html.haml
浏览文件 @
0a31efb5
...
...
@@ -23,4 +23,4 @@
to post a comment
:javascript
var
notes
=
new
Notes
(
"
#{
namespace_project_notes_path
(
namespace_id:
@project
.
namespace
,
project_id:
@project
,
target_id:
@noteable
.
id
,
target_type:
@noteable
.
class
.
name
.
underscore
)
}
"
,
#{
@notes
.
map
(
&
:id
).
to_json
}
,
#{
Time
.
now
.
to_i
}
,
"
#{
diff_view
}
"
)
var
notes
=
new
Notes
(
"
#{
namespace_project_note
able_note
s_path
(
namespace_id:
@project
.
namespace
,
project_id:
@project
,
target_id:
@noteable
.
id
,
target_type:
@noteable
.
class
.
name
.
underscore
)
}
"
,
#{
@notes
.
map
(
&
:id
).
to_json
}
,
#{
Time
.
now
.
to_i
}
,
"
#{
diff_view
}
"
)
config/routes/project.rb
浏览文件 @
0a31efb5
...
...
@@ -265,7 +265,7 @@ constraints(ProjectUrlConstrainer.new) do
resources
:group_links
,
only:
[
:index
,
:create
,
:update
,
:destroy
],
constraints:
{
id:
/\d+/
}
resources
:notes
,
only:
[
:
index
,
:
create
,
:destroy
,
:update
],
concerns: :awardable
,
constraints:
{
id:
/\d+/
}
do
resources
:notes
,
only:
[
:create
,
:destroy
,
:update
],
concerns: :awardable
,
constraints:
{
id:
/\d+/
}
do
member
do
delete
:delete_attachment
post
:resolve
...
...
@@ -273,6 +273,8 @@ constraints(ProjectUrlConstrainer.new) do
end
end
get
'noteable/:target_type/:target_id/notes'
=>
'notes#index'
,
as:
'noteable_notes'
resources
:boards
,
only:
[
:index
,
:show
]
do
scope
module: :boards
do
resources
:issues
,
only:
[
:index
,
:update
]
...
...
spec/controllers/projects/notes_controller_spec.rb
浏览文件 @
0a31efb5
...
...
@@ -200,4 +200,31 @@ describe Projects::NotesController do
end
end
end
describe
'GET index'
do
let
(
:last_fetched_at
)
{
'1487756246'
}
let
(
:request_params
)
do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
target_type:
'issue'
,
target_id:
issue
.
id
}
end
before
do
sign_in
(
user
)
project
.
team
<<
[
user
,
:developer
]
end
it
'passes last_fetched_at from headers to NotesFinder'
do
request
.
headers
[
'X-Last-Fetched-At'
]
=
last_fetched_at
expect
(
NotesFinder
).
to
receive
(
:new
)
.
with
(
anything
,
anything
,
hash_including
(
last_fetched_at:
last_fetched_at
))
.
and_call_original
get
:index
,
request_params
end
end
end
spec/routing/project_routing_spec.rb
浏览文件 @
0a31efb5
...
...
@@ -431,12 +431,22 @@ describe 'project routing' do
end
end
#
project_notes GET /:project_id/notes(.:format)
notes#index
#
project_noteable_notes GET /:project_id/noteable/:target_type/:target_id/notes
notes#index
# POST /:project_id/notes(.:format) notes#create
# project_note DELETE /:project_id/notes/:id(.:format) notes#destroy
describe
Projects
::
NotesController
,
'routing'
do
it
'to #index'
do
expect
(
get
(
'/gitlab/gitlabhq/noteable/issue/1/notes'
)).
to
route_to
(
'projects/notes#index'
,
namespace_id:
'gitlab'
,
project_id:
'gitlabhq'
,
target_type:
'issue'
,
target_id:
'1'
)
end
it_behaves_like
'RESTful project resources'
do
let
(
:actions
)
{
[
:
index
,
:
create
,
:destroy
]
}
let
(
:actions
)
{
[
:create
,
:destroy
]
}
let
(
:controller
)
{
'notes'
}
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录