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
480fcb55
Commit
480fcb55
authored
Apr 26, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added controller specs
parent
45e5d121
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
0 deletions
+95
-0
app/controllers/concerns/milestone_actions.rb
app/controllers/concerns/milestone_actions.rb
+11
-0
spec/controllers/groups/milestones_controller_spec.rb
spec/controllers/groups/milestones_controller_spec.rb
+12
-0
spec/controllers/projects/milestones_controller_spec.rb
spec/controllers/projects/milestones_controller_spec.rb
+5
-0
spec/support/milestone_tabs_examples.rb
spec/support/milestone_tabs_examples.rb
+67
-0
No files found.
app/controllers/concerns/milestone_actions.rb
View file @
480fcb55
...
...
@@ -3,6 +3,7 @@ module MilestoneActions
def
merge_requests
respond_to
do
|
format
|
format
.
html
{
redirect_to
milestone_path
}
format
.
json
do
render
json:
tabs_json
(
"shared/milestones/_merge_requests_tab"
,
{
merge_requests:
@milestone
.
merge_requests
,
...
...
@@ -14,6 +15,7 @@ module MilestoneActions
def
participants
respond_to
do
|
format
|
format
.
html
{
redirect_to
milestone_path
}
format
.
json
do
render
json:
tabs_json
(
"shared/milestones/_participants_tab"
,
{
users:
@milestone
.
participants
...
...
@@ -24,6 +26,7 @@ module MilestoneActions
def
labels
respond_to
do
|
format
|
format
.
html
{
redirect_to
milestone_path
}
format
.
json
do
render
json:
tabs_json
(
"shared/milestones/_labels_tab"
,
{
labels:
@milestone
.
labels
...
...
@@ -39,4 +42,12 @@ module MilestoneActions
html:
view_to_html_string
(
partial
,
data
)
}
end
def
milestone_path
if
@project
namespace_project_milestone_path
(
@project
.
namespace
,
@project
,
@milestone
)
else
group_milestone_path
(
@group
,
@milestone
.
safe_title
,
title:
@milestone
.
title
)
end
end
end
spec/controllers/groups/milestones_controller_spec.rb
View file @
480fcb55
...
...
@@ -6,6 +6,16 @@ describe Groups::MilestonesController do
let
(
:project2
)
{
create
(
:empty_project
,
group:
group
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:title
)
{
'肯定不是中文的问题'
}
let
(
:milestone
)
do
project_milestone
=
create
(
:milestone
,
project:
project
)
GroupMilestone
.
build
(
group
,
[
project
],
project_milestone
.
title
)
end
let
(
:milestone_path
)
{
group_milestone_path
(
group
,
milestone
.
safe_title
,
title:
milestone
.
title
)
}
before
do
sign_in
(
user
)
...
...
@@ -14,6 +24,8 @@ describe Groups::MilestonesController do
controller
.
instance_variable_set
(
:@group
,
group
)
end
it_behaves_like
'milestone tabs'
describe
"#create"
do
it
"creates group milestone with Chinese title"
do
post
:create
,
...
...
spec/controllers/projects/milestones_controller_spec.rb
View file @
480fcb55
...
...
@@ -7,6 +7,7 @@ describe Projects::MilestonesController do
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
)
}
let
(
:milestone_path
)
{
namespace_project_milestone_path
}
before
do
sign_in
(
user
)
...
...
@@ -14,6 +15,8 @@ describe Projects::MilestonesController do
controller
.
instance_variable_set
(
:@project
,
project
)
end
it_behaves_like
'milestone tabs'
describe
"#show"
do
render_views
...
...
@@ -49,4 +52,6 @@ describe Projects::MilestonesController do
expect
(
last_note
).
to
eq
(
'removed milestone'
)
end
end
end
spec/support/milestone_tabs_examples.rb
0 → 100644
View file @
480fcb55
shared_examples
'milestone tabs'
do
def
go
(
path
,
extra_params
=
{})
params
=
if
milestone
.
is_a?
(
GlobalMilestone
)
{
group_id:
group
.
id
,
id:
milestone
.
safe_title
,
title:
milestone
.
title
}
else
{
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
milestone
.
iid
}
end
get
path
,
params
.
merge
(
extra_params
)
end
describe
'#merge_requests'
do
context
'as html'
do
before
{
go
(
:merge_requests
,
format:
'html'
)
}
it
'redirects to milestone#show'
do
expect
(
response
).
to
redirect_to
(
milestone_path
)
end
end
context
'as json'
do
before
{
go
(
:merge_requests
,
format:
'json'
)
}
it
'renders the merge requests tab template to a string'
do
expect
(
response
).
to
render_template
(
'shared/milestones/_merge_requests_tab'
)
expect
(
json_response
).
to
have_key
(
'html'
)
end
end
end
describe
'#participants'
do
context
'as html'
do
before
{
go
(
:participants
,
format:
'html'
)
}
it
'redirects to milestone#show'
do
expect
(
response
).
to
redirect_to
(
milestone_path
)
end
end
context
'as json'
do
before
{
go
(
:participants
,
format:
'json'
)
}
it
'renders the participants tab template to a string'
do
expect
(
response
).
to
render_template
(
'shared/milestones/_participants_tab'
)
expect
(
json_response
).
to
have_key
(
'html'
)
end
end
end
describe
'#labels'
do
context
'as html'
do
before
{
go
(
:labels
,
format:
'html'
)
}
it
'redirects to milestone#show'
do
expect
(
response
).
to
redirect_to
(
milestone_path
)
end
end
context
'as json'
do
before
{
go
(
:labels
,
format:
'json'
)
}
it
'renders the labels tab template to a string'
do
expect
(
response
).
to
render_template
(
'shared/milestones/_labels_tab'
)
expect
(
json_response
).
to
have_key
(
'html'
)
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