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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
45a591c4
Commit
45a591c4
authored
Nov 13, 2017
by
Jarka Kadlecova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor code based on MR comments
parent
2fc79403
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
17 deletions
+29
-17
db/migrate/20171107130813_create_epic_issues_table.rb
db/migrate/20171107130813_create_epic_issues_table.rb
+0
-2
db/schema.rb
db/schema.rb
+2
-4
ee/app/services/epic_issues/create_service.rb
ee/app/services/epic_issues/create_service.rb
+1
-1
spec/ee/spec/controllers/groups/epic_issues_controller_spec.rb
...ee/spec/controllers/groups/epic_issues_controller_spec.rb
+3
-3
spec/ee/spec/models/epic_spec.rb
spec/ee/spec/models/epic_spec.rb
+7
-7
spec/ee/spec/services/epic_issues/create_service_spec.rb
spec/ee/spec/services/epic_issues/create_service_spec.rb
+16
-0
No files found.
db/migrate/20171107130813_create_epic_issues_table.rb
View file @
45a591c4
class
CreateEpicIssuesTable
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
...
...
db/schema.rb
View file @
45a591c4
...
...
@@ -735,8 +735,6 @@ ActiveRecord::Schema.define(version: 20171107144726) do
create_table
"epic_issues"
,
force: :cascade
do
|
t
|
t
.
integer
"epic_id"
,
null:
false
t
.
integer
"issue_id"
,
null:
false
t
.
datetime_with_timezone
"created_at"
t
.
datetime_with_timezone
"updated_at"
end
add_index
"epic_issues"
,
[
"epic_id"
],
name:
"index_epic_issues_on_epic_id"
,
using: :btree
...
...
@@ -2403,8 +2401,8 @@ ActiveRecord::Schema.define(version: 20171107144726) do
add_foreign_key
"deploy_keys_projects"
,
"projects"
,
name:
"fk_58a901ca7e"
,
on_delete: :cascade
add_foreign_key
"deployments"
,
"projects"
,
name:
"fk_b9a3851b82"
,
on_delete: :cascade
add_foreign_key
"environments"
,
"projects"
,
name:
"fk_d1c8c1da6a"
,
on_delete: :cascade
add_foreign_key
"epic_issues"
,
"epics"
add_foreign_key
"epic_issues"
,
"issues"
add_foreign_key
"epic_issues"
,
"epics"
,
on_delete: :cascade
add_foreign_key
"epic_issues"
,
"issues"
,
on_delete: :cascade
add_foreign_key
"epic_metrics"
,
"epics"
,
on_delete: :cascade
add_foreign_key
"epics"
,
"milestones"
,
on_delete: :nullify
add_foreign_key
"epics"
,
"namespaces"
,
column:
"group_id"
,
name:
"fk_f081aa4489"
,
on_delete: :cascade
...
...
ee/app/services/epic_issues/create_service.rb
View file @
45a591c4
spec/ee/spec/controllers/groups/epic_issues_controller_spec.rb
View file @
45a591c4
...
...
@@ -46,7 +46,7 @@ describe Groups::EpicIssuesController do
post
:create
,
group_id:
group
,
epic_id:
epic
.
to_param
,
issue_references:
reference
end
context
'when user has permissions to create requested associ
ta
ion'
do
context
'when user has permissions to create requested associ
at
ion'
do
before
do
group
.
add_developer
(
user
)
end
...
...
@@ -64,7 +64,7 @@ describe Groups::EpicIssuesController do
end
end
context
'when user does not have permissions to create requested associ
ta
ion'
do
context
'when user does not have permissions to create requested associ
at
ion'
do
it
'returns correct response for the correct issue reference'
do
subject
...
...
@@ -134,7 +134,7 @@ describe Groups::EpicIssuesController do
end
end
context
'when the epic_issue record does not exi
xst
'
do
context
'when the epic_issue record does not exi
sts
'
do
it
'returns status 404'
do
delete
:destroy
,
group_id:
group
,
epic_id:
epic
.
to_param
,
id:
9999
...
...
spec/ee/spec/models/epic_spec.rb
View file @
45a591c4
...
...
@@ -40,22 +40,22 @@ describe Epic do
]
end
subject
{
epic
.
issues
(
user
)
}
let
(
:result
)
{
epic
.
issues
(
user
)
}
it
'returns all issues if a user has access to them'
do
group
.
add_developer
(
user
)
expect
(
subjec
t
.
count
).
to
eq
(
2
)
expect
(
subjec
t
.
map
(
&
:id
)).
to
match_array
([
issue
.
id
,
other_issue
.
id
])
expect
(
subjec
t
.
map
(
&
:epic_issue_id
)).
to
match_array
(
epic_issues
.
map
(
&
:id
))
expect
(
resul
t
.
count
).
to
eq
(
2
)
expect
(
resul
t
.
map
(
&
:id
)).
to
match_array
([
issue
.
id
,
other_issue
.
id
])
expect
(
resul
t
.
map
(
&
:epic_issue_id
)).
to
match_array
(
epic_issues
.
map
(
&
:id
))
end
it
'does not return issues user can not see'
do
project
.
add_developer
(
user
)
expect
(
subjec
t
.
count
).
to
eq
(
1
)
expect
(
subjec
t
.
map
(
&
:id
)).
to
match_array
([
issue
.
id
])
expect
(
subjec
t
.
map
(
&
:epic_issue_id
)).
to
match_array
([
epic_issues
.
first
.
id
])
expect
(
resul
t
.
count
).
to
eq
(
1
)
expect
(
resul
t
.
map
(
&
:id
)).
to
match_array
([
issue
.
id
])
expect
(
resul
t
.
map
(
&
:epic_issue_id
)).
to
match_array
([
epic_issues
.
first
.
id
])
end
end
end
spec/ee/spec/services/epic_issues/create_service_spec.rb
View file @
45a591c4
...
...
@@ -59,6 +59,22 @@ describe EpicIssues::CreateService do
subject
{
assign_issue
([
valid_reference
])
}
include_examples
'returns success'
it
'does not perofrm N + 1 queries'
do
params
=
{
issue_references:
[
valid_reference
]
}
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
described_class
.
new
(
epic
,
user
,
params
).
execute
}.
count
user
=
create
(
:user
)
group
=
create
(
:group
)
project
=
create
(
:project
,
group:
group
)
issues
=
create_list
(
:issue
,
5
,
project:
project
)
epic
=
create
(
:epic
,
group:
group
)
group
.
add_developer
(
user
)
params
=
{
issue_references:
issues
.
map
{
|
i
|
i
.
to_reference
(
full:
true
)
}
}
expect
{
described_class
.
new
(
epic
,
user
,
params
).
execute
}.
not_to
exceed_query_limit
(
control_count
)
end
end
context
'when an issue links is given'
do
...
...
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