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
8281ec84
Commit
8281ec84
authored
Mar 27, 2020
by
Eugenia Grieff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
De-duplicate issues create service EE specs
rm ee/spec/services/issues/create_service_spec.rb
parent
fcf2ee20
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
105 deletions
+71
-105
.rubocop.yml
.rubocop.yml
+0
-2
ee/spec/services/ee/issues/create_service_spec.rb
ee/spec/services/ee/issues/create_service_spec.rb
+71
-25
ee/spec/services/issues/create_service_spec.rb
ee/spec/services/issues/create_service_spec.rb
+0
-78
No files found.
.rubocop.yml
View file @
8281ec84
...
...
@@ -217,14 +217,12 @@ Gitlab/DuplicateSpecLocation:
-
ee/spec/helpers/auth_helper_spec.rb
-
ee/spec/lib/gitlab/gl_repository_spec.rb
-
ee/spec/models/namespace_spec.rb
-
ee/spec/services/issues/create_service_spec.rb
-
ee/spec/services/merge_requests/create_service_spec.rb
-
ee/spec/services/merge_requests/refresh_service_spec.rb
-
ee/spec/services/merge_requests/update_service_spec.rb
-
ee/spec/services/system_hooks_service_spec.rb
-
ee/spec/helpers/ee/auth_helper_spec.rb
-
ee/spec/models/ee/namespace_spec.rb
-
ee/spec/services/ee/issues/create_service_spec.rb
-
ee/spec/services/ee/merge_requests/create_service_spec.rb
-
ee/spec/services/ee/merge_requests/refresh_service_spec.rb
-
ee/spec/services/ee/merge_requests/update_service_spec.rb
...
...
ee/spec/services/ee/issues/create_service_spec.rb
View file @
8281ec84
...
...
@@ -3,59 +3,105 @@
require
'spec_helper'
describe
Issues
::
CreateService
do
let
(
:group
)
{
create
(
:group
)
}
let
_it_be
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:
epic
)
{
create
(
:epic
,
group:
group
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:
params
)
{
{
title:
'Awesome issue'
,
description:
'please fix'
,
weight:
9
}
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
params
)
}
before
do
stub_licensed_features
(
epics:
true
)
end
describe
'#execute'
do
context
'when current user cannot admin issues in the project'
do
before
do
project
.
add_guest
(
user
)
end
context
'quick actions'
do
before
do
project
.
add_maintainer
(
user
)
it
'filters out params that cannot be set without the :admin_issue permission'
do
issue
=
service
.
execute
expect
(
issue
).
to
be_persisted
expect
(
issue
.
weight
).
to
be_nil
end
end
context
'/epic action'
do
let
(
:params
)
do
{
title:
'New issue'
,
description:
"/epic
#{
epic
.
to_reference
(
project
)
}
"
}
context
'when current user can admin issues in the project'
do
before
do
stub_licensed_features
(
epics:
true
)
project
.
add_reporter
(
user
)
end
it
'
adds an issue to the passed epic
'
do
it
'
sets permitted params correctly
'
do
issue
=
service
.
execute
expect
(
issue
).
to
be_persisted
expect
(
issue
.
epic
).
to
eq
(
epic
)
expect
(
issue
.
weight
).
to
eq
(
9
)
end
context
'when epics are enabled'
do
let_it_be
(
:epic
)
{
create
(
:epic
,
group:
group
,
start_date_is_fixed:
false
,
due_date_is_fixed:
false
)
}
before
do
stub_licensed_features
(
epics:
true
)
project
.
add_reporter
(
user
)
end
it_behaves_like
'issue with epic_id parameter'
do
let
(
:execute
)
{
service
.
execute
}
end
context
'when using quick actions'
do
before
do
group
.
add_reporter
(
user
)
end
context
'/epic action'
do
let
(
:params
)
{
{
title:
'New issue'
,
description:
"/epic
#{
epic
.
to_reference
(
project
)
}
"
}
}
it
'adds an issue to the passed epic'
do
issue
=
service
.
execute
expect
(
issue
).
to
be_persisted
expect
(
issue
.
epic
).
to
eq
(
epic
)
end
end
context
'with epic and milestone in commands only'
do
let
(
:milestone
)
{
create
(
:milestone
,
group:
group
,
start_date:
Date
.
today
,
due_date:
7
.
days
.
from_now
)
}
let
(
:params
)
do
{
title:
'Awesome issue'
,
description:
%(/epic #{epic.to_reference}\n/milestone #{milestone.to_reference}")
}
end
it
'sets epic and milestone to issuable and update epic start and due date'
do
issue
=
service
.
execute
expect
(
issue
.
milestone
).
to
eq
(
milestone
)
expect
(
issue
.
epic
).
to
eq
(
epic
)
expect
(
epic
.
reload
.
start_date
).
to
eq
(
milestone
.
start_date
)
expect
(
epic
.
due_date
).
to
eq
(
milestone
.
due_date
)
end
end
end
end
end
end
describe
'#execute'
do
it_behaves_like
'new issuable with scoped labels'
do
let
(
:parent
)
{
project
}
end
it_behaves_like
'issue with epic_id parameter'
do
let
(
:execute
)
{
service
.
execute
}
end
describe
'publish to status page'
do
let
(
:execute
)
{
service
.
execute
}
let
(
:issue_id
)
{
execute
&
.
id
}
context
'when creation succeeds'
do
let
(
:params
)
{
{
title:
'New title'
}
}
let
_it_be
(
:params
)
{
{
title:
'New title'
}
}
include_examples
'trigger status page publish'
end
context
'when creation fails'
do
let
(
:params
)
{
{
title:
nil
}
}
let
_it_be
(
:params
)
{
{
title:
nil
}
}
include_examples
'no trigger status page publish'
end
...
...
ee/spec/services/issues/create_service_spec.rb
deleted
100644 → 0
View file @
fcf2ee20
# frozen_string_literal: true
require
'spec_helper'
describe
Issues
::
CreateService
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:opts
)
do
{
title:
'Awesome issue'
,
description:
'please fix'
,
weight:
9
}
end
context
'when current user cannot admin issues in the project'
do
let
(
:guest
)
{
create
(
:user
)
}
before
do
project
.
add_guest
(
guest
)
end
it
'filters out params that cannot be set without the :admin_issue permission'
do
issue
=
described_class
.
new
(
project
,
guest
,
opts
).
execute
expect
(
issue
).
to
be_persisted
expect
(
issue
.
weight
).
to
be_nil
end
end
context
'when current user can admin issues in the project'
do
let
(
:reporter
)
{
create
(
:user
)
}
before
do
stub_licensed_features
(
epics:
true
)
project
.
add_reporter
(
reporter
)
end
it
'sets permitted params correctly'
do
issue
=
described_class
.
new
(
project
,
reporter
,
opts
).
execute
expect
(
issue
).
to
be_persisted
expect
(
issue
.
weight
).
to
eq
(
9
)
end
context
'when epics are enabled'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:project1
)
{
create
(
:project
,
group:
group
)
}
let
(
:epic
)
{
create
(
:epic
,
group:
group
,
start_date_is_fixed:
false
,
due_date_is_fixed:
false
)
}
before
do
stub_licensed_features
(
epics:
true
)
group
.
add_reporter
(
reporter
)
project1
.
add_reporter
(
reporter
)
end
context
'when using quick actions'
do
context
'with epic and milestone in commands only'
do
let
(
:milestone
)
{
create
(
:milestone
,
group:
group
,
start_date:
Date
.
today
,
due_date:
7
.
days
.
from_now
)
}
let
(
:opts
)
do
{
title:
'Awesome issue'
,
description:
%(/epic #{epic.to_reference}\n/milestone #{milestone.to_reference}")
}
end
it
'sets epic and milestone to issuable and update epic start and due date'
do
issue
=
described_class
.
new
(
project1
,
reporter
,
opts
).
execute
expect
(
issue
.
milestone
).
to
eq
(
milestone
)
expect
(
issue
.
epic
).
to
eq
(
epic
)
expect
(
epic
.
reload
.
start_date
).
to
eq
(
milestone
.
start_date
)
expect
(
epic
.
due_date
).
to
eq
(
milestone
.
due_date
)
end
end
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