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
99d2379b
Commit
99d2379b
authored
Aug 26, 2020
by
Eugenia Grieff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test examples for system notes
- Tree reorder service should create system notes when new parent is set
parent
f46565b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
64 deletions
+87
-64
ee/spec/requests/api/graphql/mutations/epic_tree/reorder_spec.rb
.../requests/api/graphql/mutations/epic_tree/reorder_spec.rb
+1
-1
ee/spec/services/epics/tree_reorder_service_spec.rb
ee/spec/services/epics/tree_reorder_service_spec.rb
+86
-63
No files found.
ee/spec/requests/api/graphql/mutations/epic_tree/reorder_spec.rb
View file @
99d2379b
...
...
@@ -49,7 +49,7 @@ RSpec.describe 'Updating an epic tree' do
end
end
context
'when epic
feature is
enabled'
do
context
'when epic
s and subepics features are
enabled'
do
before
do
stub_licensed_features
(
epics:
true
,
subepics:
true
)
end
...
...
ee/spec/services/epics/tree_reorder_service_spec.rb
View file @
99d2379b
...
...
@@ -66,7 +66,7 @@ RSpec.describe Epics::TreeReorderService do
context
'when user does have permission to admin the base epic'
do
before
do
group
.
add_
develop
er
(
user
)
group
.
add_
report
er
(
user
)
end
context
'when relative_position is not valid'
do
...
...
@@ -102,6 +102,10 @@ RSpec.describe Epics::TreeReorderService do
it
'updates the parent'
do
expect
{
subject
}.
to
change
{
tree_object_2
.
reload
.
epic
}.
from
(
epic1
).
to
(
epic
)
end
it
'creates system notes'
do
expect
{
subject
}.
to
change
{
Note
.
system
.
count
}.
by
(
3
)
end
end
context
'when object being moved is from another epic'
do
...
...
@@ -207,6 +211,10 @@ RSpec.describe Epics::TreeReorderService do
expect
(
tree_object_1
.
reload
.
relative_position
).
to
be
>
tree_object_2
.
reload
.
relative_position
end
it
'creates system notes'
do
expect
{
subject
}.
to
change
{
Note
.
system
.
count
}.
by
(
3
)
end
end
end
end
...
...
@@ -215,103 +223,118 @@ RSpec.describe Epics::TreeReorderService do
let!
(
:tree_object_1
)
{
epic1
}
let!
(
:tree_object_2
)
{
epic2
}
before
do
stub_licensed_features
(
epics:
true
,
subepics:
true
)
end
context
'when user does not have permissions to admin the previous parent'
do
let
(
:other_group
)
{
create
(
:group
)
}
let
(
:other_epic
)
{
create
(
:epic
,
group:
other_group
)
}
context
'when subepics feature is disabled'
do
let
(
:new_parent_id
)
{
GitlabSchema
.
id_from_object
(
epic
)
}
before
do
epic2
.
update
(
parent:
other_epic
)
stub_licensed_features
(
epics:
true
,
subepics:
false
)
end
it_behaves_like
'error for the tree update'
,
'You don\'t have permissions to move the objects.'
end
context
'when there is some other error with the new parent'
do
let
(
:other_group
)
{
create
(
:group
)
}
let
(
:new_parent_id
)
{
GitlabSchema
.
id_from_object
(
epic
)
}
context
'when subepics feature is enabled'
do
before
do
other_group
.
add_developer
(
user
)
epic
.
update
(
group:
other_group
)
epic2
.
update
(
parent:
epic1
)
stub_licensed_features
(
epics:
true
,
subepics:
true
)
end
it_behaves_like
'error for the tree update'
,
"This epic cannot be added. An epic must belong to the same group or subgroup as its parent epic."
end
context
'when user does not have permissions to admin the previous parent'
do
let
(
:other_group
)
{
create
(
:group
)
}
let
(
:other_epic
)
{
create
(
:epic
,
group:
other_group
)
}
let
(
:new_parent_id
)
{
GitlabSchema
.
id_from_object
(
epic
)
}
context
'when user does not have permissions to admin the new parent'
do
let
(
:other_group
)
{
create
(
:group
)
}
let
(
:other_epic
)
{
create
(
:epic
,
group:
other_group
)
}
let
(
:new_parent_id
)
{
GitlabSchema
.
id_from_object
(
other_epic
)
}
before
do
epic2
.
update
(
parent:
other_epic
)
end
it_behaves_like
'error for the tree update'
,
'You don\'t have permissions to move the objects.'
end
it_behaves_like
'error for the tree update'
,
'You don\'t have permissions to move the objects.'
end
context
'when the reordered epics are not subepics of the base epic'
do
let
(
:another_group
)
{
create
(
:group
)
}
let
(
:another_epic
)
{
create
(
:epic
,
group:
another_group
)
}
context
'when user does not have permissions to admin the previous parent links'
do
let
(
:new_parent_id
)
{
GitlabSchema
.
id_from_object
(
epic
)
}
before
do
epic1
.
update
(
group:
another_group
,
parent:
another_epic
)
epic2
.
update
(
group:
another_group
,
parent:
another_epic
)
before
do
group
.
add_guest
(
user
)
end
it_behaves_like
'error for the tree update'
,
'You don\'t have permissions to move the objects.'
end
it_behaves_like
'error for the tree update'
,
'You don\'t have permissions to move the objects.'
end
context
'when there is some other error with the new parent'
do
let
(
:other_group
)
{
create
(
:group
)
}
let
(
:new_parent_id
)
{
GitlabSchema
.
id_from_object
(
epic
)
}
context
'when new parent is another epic and subepics feature is disabled'
do
let
(
:other_epic
)
{
create
(
:epic
,
group:
group
)
}
let
(
:new_parent_id
)
{
GitlabSchema
.
id_from_object
(
epic
)
}
let
(
:epic3
)
{
create
(
:epic
,
parent:
other_epic
,
group:
group
)
}
let
(
:tree_object_2
)
{
epic3
}
before
do
other_group
.
add_developer
(
user
)
epic
.
update
(
group:
other_group
)
epic2
.
update
(
parent:
epic1
)
end
before
do
stub_licensed_features
(
epics:
true
,
subepics:
false
)
it_behaves_like
'error for the tree update'
,
"This epic cannot be added. An epic must belong to the same group or subgroup as its parent epic."
end
it_behaves_like
'error for the tree update'
,
'You don\'t have permissions to move the objects.'
end
context
'when user does not have permissions to admin the new parent'
do
let
(
:other_group
)
{
create
(
:group
)
}
let
(
:other_epic
)
{
create
(
:epic
,
group:
other_group
)
}
let
(
:new_parent_id
)
{
GitlabSchema
.
id_from_object
(
other_epic
)
}
context
'when moving is successful'
do
it
'updates the links relative positions'
do
subject
expect
(
tree_object_1
.
reload
.
relative_position
).
to
be
>
tree_object_2
.
reload
.
relative_position
it_behaves_like
'error for the tree update'
,
'You don\'t have permissions to move the objects.'
end
context
'when new parent is current epic'
do
let
(
:new_parent_id
)
{
GitlabSchema
.
id_from_object
(
epic
)
}
context
'when user '
it
'updates the relative positions'
do
subject
context
'when the reordered epics are not subepics of the base epic'
do
let
(
:another_group
)
{
create
(
:group
)
}
let
(
:another_epic
)
{
create
(
:epic
,
group:
another_group
)
}
expect
(
tree_object_1
.
reload
.
relative_position
).
to
be
>
tree_object_2
.
reload
.
relative_position
before
do
epic1
.
update
(
group:
another_group
,
parent:
another_epic
)
epic2
.
update
(
group:
another_group
,
parent:
another_epic
)
end
it
'does not update the parent_id'
do
expect
{
subject
}.
not_to
change
{
tree_object_2
.
reload
.
parent
}
end
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 another epic and new_parent_id matches parent of adjacent object'
do
let
(
:other_epic
)
{
create
(
:epic
,
group:
group
)
}
let
(
:new_parent_id
)
{
GitlabSchema
.
id_from_object
(
epic
)
}
let
(
:epic3
)
{
create
(
:epic
,
parent:
other_epic
,
group:
group
)
}
let
(
:tree_object_2
)
{
epic3
}
it
'updates the relative positions and parent_id'
do
context
'when moving is successful'
do
it
'updates the links relative positions'
do
subject
expect
(
tree_object_1
.
reload
.
relative_position
).
to
be
>
tree_object_2
.
reload
.
relative_position
end
it
'updates the parent'
do
expect
{
subject
}.
to
change
{
tree_object_2
.
reload
.
parent
}.
from
(
other_epic
).
to
(
epic
)
context
'when new parent is current epic'
do
let
(
:new_parent_id
)
{
GitlabSchema
.
id_from_object
(
epic
)
}
it
'updates the relative positions'
do
subject
expect
(
tree_object_1
.
reload
.
relative_position
).
to
be
>
tree_object_2
.
reload
.
relative_position
end
it
'does not update the parent_id'
do
expect
{
subject
}.
not_to
change
{
tree_object_2
.
reload
.
parent
}
end
end
context
'when object being moved is from another epic and new_parent_id matches parent of adjacent object'
do
let
(
:other_epic
)
{
create
(
:epic
,
group:
group
)
}
let
(
:new_parent_id
)
{
GitlabSchema
.
id_from_object
(
epic
)
}
let
(
:epic3
)
{
create
(
:epic
,
parent:
other_epic
,
group:
group
)
}
let
(
:tree_object_2
)
{
epic3
}
it
'updates the relative positions'
do
subject
expect
(
tree_object_1
.
reload
.
relative_position
).
to
be
>
tree_object_2
.
reload
.
relative_position
end
it
'updates the parent'
do
expect
{
subject
}.
to
change
{
tree_object_2
.
reload
.
parent
}.
from
(
other_epic
).
to
(
epic
)
end
it
'creates system notes'
do
expect
{
subject
}.
to
change
{
Note
.
system
.
count
}.
by
(
2
)
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