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
Jérome Perrin
gitlab-ce
Commits
68bb2a53
Commit
68bb2a53
authored
Apr 24, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize project namespace lookup for milestones and add specs
parent
bbcb7e5e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
5 deletions
+24
-5
app/controllers/projects/milestones_controller.rb
app/controllers/projects/milestones_controller.rb
+1
-0
app/views/shared/milestones/_issuable.html.haml
app/views/shared/milestones/_issuable.html.haml
+8
-5
spec/controllers/projects/milestones_controller_spec.rb
spec/controllers/projects/milestones_controller_spec.rb
+15
-0
No files found.
app/controllers/projects/milestones_controller.rb
View file @
68bb2a53
...
...
@@ -23,6 +23,7 @@ class Projects::MilestonesController < Projects::ApplicationController
respond_to
do
|
format
|
format
.
html
do
@project_namespace
=
@project
.
namespace
.
becomes
(
Namespace
)
@milestones
=
@milestones
.
includes
(
:project
)
@milestones
=
@milestones
.
page
(
params
[
:page
])
end
...
...
app/views/shared/milestones/_issuable.html.haml
View file @
68bb2a53
-# @project is present when viewing Project's milestone
-
project
=
@project
||
issuable
.
project
-
namespace
=
@project_namespace
||
project
.
namespace
.
becomes
(
Namespace
)
-
assignee
=
issuable
.
assignee
-
issuable_type
=
issuable
.
class
.
table_name
-
base_url_args
=
[
project
.
namespace
.
becomes
(
Namespace
),
project
,
issuable_type
]
-
base_url_args
=
[
namespace
,
project
]
-
issuable_type_args
=
base_url_args
+
[
issuable_type
]
-
issuable_url_args
=
base_url_args
+
[
issuable
]
-
can_update
=
can?
(
current_user
,
:"update_
#{
issuable
.
to_ability_name
}
"
,
issuable
)
%li
{
id:
dom_id
(
issuable
,
'sortable'
),
class:
"issuable-row #{'is-disabled' unless can_update}"
,
'data-iid'
=>
issuable
.
iid
,
'data-id'
=>
issuable
.
id
,
'data-url'
=>
polymorphic_path
(
[
project
.
namespace
.
becomes
(
Namespace
),
project
,
issuable
]
)
}
%li
{
id:
dom_id
(
issuable
,
'sortable'
),
class:
"issuable-row #{'is-disabled' unless can_update}"
,
'data-iid'
=>
issuable
.
iid
,
'data-id'
=>
issuable
.
id
,
'data-url'
=>
polymorphic_path
(
issuable_url_args
)
}
%span
-
if
show_project_name
%strong
#{
project
.
name
}
·
...
...
@@ -13,17 +16,17 @@
%strong
#{
project
.
name_with_namespace
}
·
-
if
issuable
.
is_a?
(
Issue
)
=
confidential_icon
(
issuable
)
=
link_to_gfm
issuable
.
title
,
[
project
.
namespace
.
becomes
(
Namespace
),
project
,
issuable
]
,
title:
issuable
.
title
=
link_to_gfm
issuable
.
title
,
issuable_url_args
,
title:
issuable
.
title
.issuable-detail
=
link_to
[
project
.
namespace
.
becomes
(
Namespace
),
project
,
issuable
]
do
%span
.issuable-number
=
issuable
.
to_reference
-
issuable
.
labels
.
each
do
|
label
|
=
link_to
polymorphic_path
(
base_url
_args
,
{
milestone_title:
@milestone
.
title
,
label_name:
label
.
title
,
state:
'all'
})
do
=
link_to
polymorphic_path
(
issuable_type
_args
,
{
milestone_title:
@milestone
.
title
,
label_name:
label
.
title
,
state:
'all'
})
do
-
render_colored_label
(
label
)
%span
.assignee-icon
-
if
assignee
=
link_to
polymorphic_path
(
base_url
_args
,
{
milestone_title:
@milestone
.
title
,
assignee_id:
issuable
.
assignee_id
,
state:
'all'
}),
=
link_to
polymorphic_path
(
issuable_type
_args
,
{
milestone_title:
@milestone
.
title
,
assignee_id:
issuable
.
assignee_id
,
state:
'all'
}),
class:
'has-tooltip'
,
title:
"Assigned to
#{
assignee
.
name
}
"
,
data:
{
container:
'body'
}
do
-
image_tag
(
avatar_icon
(
issuable
.
assignee
,
16
),
class:
"avatar s16"
,
alt:
''
)
spec/controllers/projects/milestones_controller_spec.rb
View file @
68bb2a53
...
...
@@ -5,6 +5,7 @@ describe Projects::MilestonesController do
let
(
:user
)
{
create
(
:user
)
}
let
(
:milestone
)
{
create
(
:milestone
,
project:
project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
milestone:
milestone
)
}
let!
(
:label
)
{
create
(
:label
,
project:
project
,
title:
'Issue Label'
,
issues:
[
issue
])
}
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
,
milestone:
milestone
)
}
before
do
...
...
@@ -13,6 +14,20 @@ describe Projects::MilestonesController do
controller
.
instance_variable_set
(
:@project
,
project
)
end
describe
"#show"
do
render_views
def
view_milestone
get
:show
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
milestone
.
iid
end
it
'shows milestone page'
do
view_milestone
expect
(
response
).
to
have_http_status
(
200
)
end
end
describe
"#destroy"
do
it
"removes milestone"
do
expect
(
issue
.
milestone_id
).
to
eq
(
milestone
.
id
)
...
...
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