Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
914f9731
Commit
914f9731
authored
Jun 17, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed update method
Re-structured controller spec Renamed issuable param to issuable_id
parent
a210cd1f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
89 deletions
+83
-89
app/assets/javascripts/right_sidebar.js.coffee
app/assets/javascripts/right_sidebar.js.coffee
+1
-1
app/views/shared/issuable/_sidebar.html.haml
app/views/shared/issuable/_sidebar.html.haml
+1
-1
config/routes.rb
config/routes.rb
+1
-1
spec/controllers/projects/todo_controller_spec.rb
spec/controllers/projects/todo_controller_spec.rb
+80
-86
No files found.
app/assets/javascripts/right_sidebar.js.coffee
View file @
914f9731
...
@@ -63,7 +63,7 @@ class @Sidebar
...
@@ -63,7 +63,7 @@ class @Sidebar
type
:
ajaxType
type
:
ajaxType
dataType
:
'json'
dataType
:
'json'
data
:
data
:
issuable_id
:
$this
.
data
(
'issuable'
)
issuable_id
:
$this
.
data
(
'issuable
-id
'
)
issuable_type
:
$this
.
data
(
'issuable-type'
)
issuable_type
:
$this
.
data
(
'issuable-type'
)
beforeSend
:
=>
beforeSend
:
=>
@
beforeTodoSend
(
$this
,
$todoLoading
)
@
beforeTodoSend
(
$this
,
$todoLoading
)
...
...
app/views/shared/issuable/_sidebar.html.haml
View file @
914f9731
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
%a
.gutter-toggle.pull-right.js-sidebar-toggle
{
role:
"button"
,
href:
"#"
,
aria:
{
label:
"Toggle sidebar"
}
}
%a
.gutter-toggle.pull-right.js-sidebar-toggle
{
role:
"button"
,
href:
"#"
,
aria:
{
label:
"Toggle sidebar"
}
}
=
sidebar_gutter_toggle_icon
=
sidebar_gutter_toggle_icon
-
if
current_user
-
if
current_user
%button
.btn.btn-default.issuable-header-btn.pull-right.js-issuable-todo
{
type:
"button"
,
aria:
{
label:
(
todo
.
nil?
?
"Add Todo"
:
"Mark Done"
)
},
data:
{
todo_text:
"Add Todo"
,
mark_text:
"Mark Done"
,
issuable:
issuable
.
id
,
issuable_type:
issuable
.
class
.
name
.
underscore
,
url:
namespace_project_todos_path
(
@project
.
namespace
,
@project
),
delete_path:
(
dashboard_todo_path
(
todo
)
if
todo
)
}
}
%button
.btn.btn-default.issuable-header-btn.pull-right.js-issuable-todo
{
type:
"button"
,
aria:
{
label:
(
todo
.
nil?
?
"Add Todo"
:
"Mark Done"
)
},
data:
{
todo_text:
"Add Todo"
,
mark_text:
"Mark Done"
,
issuable
_id
:
issuable
.
id
,
issuable_type:
issuable
.
class
.
name
.
underscore
,
url:
namespace_project_todos_path
(
@project
.
namespace
,
@project
),
delete_path:
(
dashboard_todo_path
(
todo
)
if
todo
)
}
}
%span
.js-issuable-todo-text
%span
.js-issuable-todo-text
-
if
todo
-
if
todo
Mark Done
Mark Done
...
...
config/routes.rb
View file @
914f9731
...
@@ -797,7 +797,7 @@ Rails.application.routes.draw do
...
@@ -797,7 +797,7 @@ Rails.application.routes.draw do
end
end
end
end
resources
:todos
,
only:
[
:create
,
:update
]
resources
:todos
,
only:
[
:create
]
resources
:uploads
,
only:
[
:create
]
do
resources
:uploads
,
only:
[
:create
]
do
collection
do
collection
do
...
...
spec/controllers/projects/todo_controller_spec.rb
View file @
914f9731
...
@@ -7,7 +7,8 @@ describe Projects::TodosController do
...
@@ -7,7 +7,8 @@ describe Projects::TodosController do
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
context
'Issues'
do
context
'Issues'
do
describe
'POST #create'
do
describe
'POST create'
do
context
'when authorized'
do
before
do
before
do
sign_in
(
user
)
sign_in
(
user
)
project
.
team
<<
[
user
,
:developer
]
project
.
team
<<
[
user
,
:developer
]
...
@@ -18,91 +19,84 @@ describe Projects::TodosController do
...
@@ -18,91 +19,84 @@ describe Projects::TodosController do
post
(
:create
,
namespace_id:
project
.
namespace
.
path
,
post
(
:create
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
project_id:
project
.
path
,
issuable_id:
issue
.
id
,
issuable_id:
issue
.
id
,
issuable_type:
"issue"
)
issuable_type:
'issue'
)
end
.
to
change
{
user
.
todos
.
count
}.
by
(
1
)
end
.
to
change
{
user
.
todos
.
count
}.
by
(
1
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
end
end
end
end
describe
'POST #create
when not authorized'
do
context
'
when not authorized'
do
before
do
it
'should not create todo for issue that user has no access to'
do
sign_in
(
user
)
sign_in
(
user
)
end
it
'should create todo for issue'
do
expect
do
expect
do
post
(
:create
,
namespace_id:
project
.
namespace
.
path
,
post
(
:create
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
project_id:
project
.
path
,
issuable_id:
issue
.
id
,
issuable_id:
issue
.
id
,
issuable_type:
"issue"
)
issuable_type:
'issue'
)
end
.
to
change
{
user
.
todos
.
count
}.
by
(
0
)
end
.
to
change
{
user
.
todos
.
count
}.
by
(
0
)
expect
(
response
.
status
).
to
eq
(
404
)
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
describe
'POST #create when not logged in'
do
it
'should not create todo for issue when user not logged in'
do
it
'should create todo for issue'
do
expect
do
expect
do
post
(
:create
,
namespace_id:
project
.
namespace
.
path
,
post
(
:create
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
project_id:
project
.
path
,
issuable_id:
issue
.
id
,
issuable_id:
issue
.
id
,
issuable_type:
"issue"
)
issuable_type:
'issue'
)
end
.
to
change
{
user
.
todos
.
count
}.
by
(
0
)
end
.
to
change
{
user
.
todos
.
count
}.
by
(
0
)
expect
(
response
.
status
).
to
eq
(
302
)
expect
(
response
.
status
).
to
eq
(
302
)
end
end
end
end
end
end
end
context
'Merge Requests'
do
context
'Merge Requests'
do
describe
'POST #create'
do
describe
'POST create'
do
context
'when authorized'
do
before
do
before
do
sign_in
(
user
)
sign_in
(
user
)
project
.
team
<<
[
user
,
:developer
]
project
.
team
<<
[
user
,
:developer
]
end
end
it
'should create todo for issue
'
do
it
'should create todo for merge request
'
do
expect
do
expect
do
post
(
:create
,
namespace_id:
project
.
namespace
.
path
,
post
(
:create
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
project_id:
project
.
path
,
issuable_id:
merge_request
.
id
,
issuable_id:
merge_request
.
id
,
issuable_type:
"merge_request"
)
issuable_type:
'merge_request'
)
end
.
to
change
{
user
.
todos
.
count
}.
by
(
1
)
end
.
to
change
{
user
.
todos
.
count
}.
by
(
1
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
end
end
end
end
describe
'POST #create
when not authorized'
do
context
'
when not authorized'
do
before
do
it
'should not create todo for merge request user has no access to'
do
sign_in
(
user
)
sign_in
(
user
)
end
it
'should create todo for issue'
do
expect
do
expect
do
post
(
:create
,
namespace_id:
project
.
namespace
.
path
,
post
(
:create
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
project_id:
project
.
path
,
issuable_id:
merge_request
.
id
,
issuable_id:
merge_request
.
id
,
issuable_type:
"merge_request"
)
issuable_type:
'merge_request'
)
end
.
to
change
{
user
.
todos
.
count
}.
by
(
0
)
end
.
to
change
{
user
.
todos
.
count
}.
by
(
0
)
expect
(
response
.
status
).
to
eq
(
404
)
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
describe
'POST #create when not logged in'
do
it
'should not create todo for merge request user has no access to'
do
it
'should create todo for issue'
do
expect
do
expect
do
post
(
:create
,
namespace_id:
project
.
namespace
.
path
,
post
(
:create
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
project_id:
project
.
path
,
issuable_id:
merge_request
.
id
,
issuable_id:
merge_request
.
id
,
issuable_type:
"merge_request"
)
issuable_type:
'merge_request'
)
end
.
to
change
{
user
.
todos
.
count
}.
by
(
0
)
end
.
to
change
{
user
.
todos
.
count
}.
by
(
0
)
expect
(
response
.
status
).
to
eq
(
302
)
expect
(
response
.
status
).
to
eq
(
302
)
end
end
end
end
end
end
end
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