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
18b1cae4
Commit
18b1cae4
authored
Sep 30, 2019
by
Jarka Košanová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for adjacent_reference type
- and improve specs
parent
046f4323
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
33 deletions
+38
-33
ee/app/models/epic_issue.rb
ee/app/models/epic_issue.rb
+1
-0
ee/app/services/epics/tree_reorder_service.rb
ee/app/services/epics/tree_reorder_service.rb
+10
-1
ee/spec/models/concerns/epic_tree_sorting_spec.rb
ee/spec/models/concerns/epic_tree_sorting_spec.rb
+0
-1
ee/spec/models/epic_issue_spec.rb
ee/spec/models/epic_issue_spec.rb
+0
-27
ee/spec/requests/api/graphql/mutations/epic_tree/reorder_spec.rb
.../requests/api/graphql/mutations/epic_tree/reorder_spec.rb
+4
-4
ee/spec/services/epics/tree_reorder_service_spec.rb
ee/spec/services/epics/tree_reorder_service_spec.rb
+23
-0
No files found.
ee/app/models/epic_issue.rb
View file @
18b1cae4
...
...
@@ -10,6 +10,7 @@ class EpicIssue < ApplicationRecord
belongs_to
:issue
alias_attribute
:parent_ids
,
:epic_id
alias_attribute
:parent
,
:epic
scope
:in_epic
,
->
(
epic_id
)
{
where
(
epic_id:
epic_id
)
}
end
ee/app/services/epics/tree_reorder_service.rb
View file @
18b1cae4
...
...
@@ -39,11 +39,20 @@ module Epics
end
def
validate_objects
unless
moving_object
.
is_a?
(
EpicIssue
)
||
moving_object
.
is_a?
(
Epic
)
unless
supported_type?
(
moving_object
)
&&
supported_type?
(
adjacent_reference
)
return
'Only epics and epic_issues are supported.'
end
return
'You don\'t have permissions to move the objects.'
unless
authorized?
return
'Both object have to belong to same parent epic.'
unless
same_parent?
end
def
same_parent?
moving_object
.
parent
==
adjacent_reference
.
parent
end
def
supported_type?
(
object
)
object
.
is_a?
(
EpicIssue
)
||
object
.
is_a?
(
Epic
)
end
def
authorized?
...
...
ee/spec/models/concerns/epic_tree_sorting_spec.rb
View file @
18b1cae4
...
...
@@ -8,7 +8,6 @@ describe EpicTreeSorting do
let!
(
:epic_issue1
)
{
create
(
:epic_issue
,
epic:
base_epic
,
relative_position:
10
)
}
let!
(
:epic_issue2
)
{
create
(
:epic_issue
,
epic:
base_epic
,
relative_position:
500
)
}
let!
(
:epic_issue3
)
{
create
(
:epic_issue
,
epic:
base_epic
,
relative_position:
1002
)
}
let!
(
:epic_issue4
)
{
create
(
:epic_issue
,
epic:
base_epic
,
relative_position:
1500
)
}
let!
(
:epic1
)
{
create
(
:epic
,
parent:
base_epic
,
group:
group
,
relative_position:
100
)
}
let!
(
:epic2
)
{
create
(
:epic
,
parent:
base_epic
,
group:
group
,
relative_position:
1000
)
}
let!
(
:epic3
)
{
create
(
:epic
,
parent:
base_epic
,
group:
group
,
relative_position:
1001
)
}
...
...
ee/spec/models/epic_issue_spec.rb
View file @
18b1cae4
...
...
@@ -10,31 +10,4 @@ describe EpicIssue do
let
(
:default_params
)
{
{
epic:
epic
}
}
end
end
context
'relative positioning with 2 classes'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:base_epic
)
{
create
(
:epic
,
group:
group
)
}
let!
(
:epic_issue1
)
{
create
(
:epic_issue
,
epic:
base_epic
,
relative_position:
10
)
}
let!
(
:epic_issue2
)
{
create
(
:epic_issue
,
epic:
base_epic
,
relative_position:
50
)
}
let!
(
:epic_issue3
)
{
create
(
:epic_issue
,
epic:
base_epic
,
relative_position:
1500
)
}
let!
(
:epic1
)
{
create
(
:epic
,
parent:
base_epic
,
group:
group
,
relative_position:
1000
)
}
let!
(
:epic2
)
{
create
(
:epic
,
parent:
base_epic
,
group:
group
,
relative_position:
2000
)
}
context
'#move_after'
do
it
'moves the epic after an epic_issue'
do
epic1
.
move_after
(
epic_issue3
)
expect
(
epic1
.
relative_position
).
to
be
>
epic_issue3
.
relative_position
end
end
context
'#move_between'
do
it
'moves the epic between epic_issues'
do
epic1
.
move_between
(
epic_issue1
,
epic_issue2
)
expect
(
epic1
.
relative_position
).
to
be
>
epic_issue1
.
relative_position
expect
(
epic1
.
relative_position
).
to
be
<
epic_issue2
.
relative_position
end
end
end
end
ee/spec/requests/api/graphql/mutations/epic_tree/reorder_spec.rb
View file @
18b1cae4
...
...
@@ -106,7 +106,7 @@ describe 'Updating an epic tree' do
end
end
context
'when moving an epic fails'
do
context
'when moving an epic fails
due another parent
'
do
let
(
:epic2
)
{
create
(
:epic
,
relative_position:
20
)
}
it_behaves_like
'a mutation that does not update the tree'
...
...
@@ -114,7 +114,7 @@ describe 'Updating an epic tree' do
it
'returns the error message'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
mutation_response
[
'errors'
]).
to
eq
([
'
Epic not found for given params
'
])
expect
(
mutation_response
[
'errors'
]).
to
eq
([
'
Both object have to belong to same parent epic.
'
])
end
end
end
...
...
@@ -138,7 +138,7 @@ describe 'Updating an epic tree' do
end
end
context
'when moving an issue fails'
do
context
'when moving an issue fails
due to another parent
'
do
let
(
:epic_issue2
)
{
create
(
:epic_issue
,
relative_position:
20
)
}
before
do
...
...
@@ -151,7 +151,7 @@ describe 'Updating an epic tree' do
it
'returns the error message'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
mutation_response
[
'errors'
]).
to
eq
([
'
Epic issue not found for given params
'
])
expect
(
mutation_response
[
'errors'
]).
to
eq
([
'
Both object have to belong to same parent epic.
'
])
end
end
end
...
...
ee/spec/services/epics/tree_reorder_service_spec.rb
View file @
18b1cae4
...
...
@@ -87,8 +87,22 @@ describe Epics::TreeReorderService do
end
end
context
'when object being moved is from of another epic'
do
before
do
other_epic
=
create
(
:epic
,
group:
group
)
epic_issue2
.
update
(
epic:
other_epic
)
end
it_behaves_like
'error for the tree update'
,
'Both object have to belong to same parent epic.'
end
context
'when object being moved is not supported type'
do
let
(
:moving_object_id
)
{
GitlabSchema
.
id_from_object
(
issue1
)
}
it_behaves_like
'error for the tree update'
,
'Only epics and epic_issues are supported.'
end
context
'when adjacent object is not supported type'
do
let
(
:adjacent_reference_id
)
{
GitlabSchema
.
id_from_object
(
issue2
)
}
it_behaves_like
'error for the tree update'
,
'Only epics and epic_issues are supported.'
...
...
@@ -131,6 +145,15 @@ describe Epics::TreeReorderService do
it_behaves_like
'error for the tree update'
,
'You don\'t have permissions to move the objects.'
end
context
'when object being moved is from of another epic'
do
before
do
other_epic
=
create
(
:epic
,
group:
group
)
epic2
.
update
(
parent:
other_epic
)
end
it_behaves_like
'error for the tree update'
,
'Both object have to belong to same parent epic.'
end
context
'when moving is successful'
do
it
'updates the links relative positions'
do
subject
...
...
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