BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
0a31efb5
Commit
0a31efb5
authored
Feb 07, 2017
by
Adam Niedzielski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove query parameters from notes polling endpoint to make caching easier
parent
57c068e1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
8 deletions
+52
-8
notes.js
app/assets/javascripts/notes.js
+1
-1
notes_controller.rb
app/controllers/projects/notes_controller.rb
+6
-1
_notes_with_form.html.haml
app/views/projects/notes/_notes_with_form.html.haml
+1
-1
project.rb
config/routes/project.rb
+3
-1
notes_controller_spec.rb
spec/controllers/projects/notes_controller_spec.rb
+27
-0
project_routing_spec.rb
spec/routing/project_routing_spec.rb
+14
-4
No files found.
app/assets/javascripts/notes.js
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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
View file @
0a31efb5
...
...
@@ -431,12 +431,22 @@ describe 'project routing' do
end
end
#
project_notes GET /:project_id/notes(.:format)
notes#index
#
POST /:project_id/notes(.:format)
notes#create
#
project_note DELETE /:project_id/notes/:id(.:format)
notes#destroy
#
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment