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
5d373fdd
Commit
5d373fdd
authored
Apr 02, 2019
by
Alexandru Croitor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract EE specific files/lines for quick actions tests
Extract EE specific quick action specs to ee/specs folder
parent
1871caf3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
139 additions
and
95 deletions
+139
-95
ee/spec/services/ee/notes/quick_actions_service_spec.rb
ee/spec/services/ee/notes/quick_actions_service_spec.rb
+26
-0
ee/spec/services/quick_actions/interpret_service_spec.rb
ee/spec/services/quick_actions/interpret_service_spec.rb
+108
-6
spec/services/notes/quick_actions_service_spec.rb
spec/services/notes/quick_actions_service_spec.rb
+3
-2
spec/services/quick_actions/interpret_service_spec.rb
spec/services/quick_actions/interpret_service_spec.rb
+2
-87
No files found.
ee/spec/services/ee/notes/quick_actions_service_spec.rb
View file @
5d373fdd
...
@@ -231,4 +231,30 @@ describe Notes::QuickActionsService do
...
@@ -231,4 +231,30 @@ describe Notes::QuickActionsService do
end
end
end
end
end
end
context
'Issue assignees'
do
describe
'/assign'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:maintainer
)
{
create
(
:user
).
tap
{
|
u
|
project
.
add_maintainer
(
u
)
}
}
let
(
:assignee
)
{
create
(
:user
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
maintainer
)
}
let
(
:note
)
{
create
(
:note_on_issue
,
note:
note_text
,
project:
project
)
}
let
(
:note_text
)
do
%(/assign @#{assignee.username} @#{maintainer.username}\n")
end
before
do
project
.
add_maintainer
(
maintainer
)
project
.
add_maintainer
(
assignee
)
end
it
'adds multiple assignees from the list'
do
_
,
update_params
=
service
.
execute
(
note
)
service
.
apply_updates
(
update_params
,
note
)
expect
(
note
.
noteable
.
assignees
.
count
).
to
eq
(
2
)
end
end
end
end
end
ee/spec/services/quick_actions/interpret_service_spec.rb
View file @
5d373fdd
...
@@ -17,10 +17,12 @@ describe QuickActions::InterpretService do
...
@@ -17,10 +17,12 @@ describe QuickActions::InterpretService do
end
end
describe
'#execute'
do
describe
'#execute'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
context
'assign command'
do
context
'assign command'
do
context
'Issue'
do
context
'Issue'
do
it
'fetches assignees and populates them if content contains /assign'
do
it
'fetches assignees and populates them if content contains /assign'
do
issue
.
update
(
assignee_ids:
[
user
.
id
,
user2
.
id
])
issue
.
update
!
(
assignee_ids:
[
user
.
id
,
user2
.
id
])
_
,
updates
=
service
.
execute
(
"/unassign @
#{
user2
.
username
}
\n
/assign @
#{
user3
.
username
}
"
,
issue
)
_
,
updates
=
service
.
execute
(
"/unassign @
#{
user2
.
username
}
\n
/assign @
#{
user3
.
username
}
"
,
issue
)
...
@@ -29,7 +31,7 @@ describe QuickActions::InterpretService do
...
@@ -29,7 +31,7 @@ describe QuickActions::InterpretService do
context
'assign command with multiple assignees'
do
context
'assign command with multiple assignees'
do
it
'fetches assignee and populates assignee_ids if content contains /assign'
do
it
'fetches assignee and populates assignee_ids if content contains /assign'
do
issue
.
update
(
assignee_ids:
[
user
.
id
])
issue
.
update
!
(
assignee_ids:
[
user
.
id
])
_
,
updates
=
service
.
execute
(
"/unassign @
#{
user
.
username
}
\n
/assign @
#{
user2
.
username
}
@
#{
user3
.
username
}
"
,
issue
)
_
,
updates
=
service
.
execute
(
"/unassign @
#{
user
.
username
}
\n
/assign @
#{
user2
.
username
}
@
#{
user3
.
username
}
"
,
issue
)
...
@@ -44,7 +46,7 @@ describe QuickActions::InterpretService do
...
@@ -44,7 +46,7 @@ describe QuickActions::InterpretService do
context
'Issue'
do
context
'Issue'
do
it
'unassigns user if content contains /unassign @user'
do
it
'unassigns user if content contains /unassign @user'
do
issue
.
update
(
assignee_ids:
[
user
.
id
,
user2
.
id
])
issue
.
update
!
(
assignee_ids:
[
user
.
id
,
user2
.
id
])
_
,
updates
=
service
.
execute
(
"/assign @
#{
user3
.
username
}
\n
/unassign @
#{
user2
.
username
}
"
,
issue
)
_
,
updates
=
service
.
execute
(
"/assign @
#{
user3
.
username
}
\n
/unassign @
#{
user2
.
username
}
"
,
issue
)
...
@@ -52,7 +54,7 @@ describe QuickActions::InterpretService do
...
@@ -52,7 +54,7 @@ describe QuickActions::InterpretService do
end
end
it
'unassigns both users if content contains /unassign @user @user1'
do
it
'unassigns both users if content contains /unassign @user @user1'
do
issue
.
update
(
assignee_ids:
[
user
.
id
,
user2
.
id
])
issue
.
update
!
(
assignee_ids:
[
user
.
id
,
user2
.
id
])
_
,
updates
=
service
.
execute
(
"/assign @
#{
user3
.
username
}
\n
/unassign @
#{
user2
.
username
}
@
#{
user3
.
username
}
"
,
issue
)
_
,
updates
=
service
.
execute
(
"/assign @
#{
user3
.
username
}
\n
/unassign @
#{
user2
.
username
}
@
#{
user3
.
username
}
"
,
issue
)
...
@@ -60,7 +62,7 @@ describe QuickActions::InterpretService do
...
@@ -60,7 +62,7 @@ describe QuickActions::InterpretService do
end
end
it
'unassigns all the users if content contains /unassign'
do
it
'unassigns all the users if content contains /unassign'
do
issue
.
update
(
assignee_ids:
[
user
.
id
,
user2
.
id
])
issue
.
update
!
(
assignee_ids:
[
user
.
id
,
user2
.
id
])
_
,
updates
=
service
.
execute
(
"/assign @
#{
user3
.
username
}
\n
/unassign"
,
issue
)
_
,
updates
=
service
.
execute
(
"/assign @
#{
user3
.
username
}
\n
/unassign"
,
issue
)
...
@@ -86,7 +88,7 @@ describe QuickActions::InterpretService do
...
@@ -86,7 +88,7 @@ describe QuickActions::InterpretService do
let
(
:content
)
{
"/reassign @
#{
current_user
.
username
}
"
}
let
(
:content
)
{
"/reassign @
#{
current_user
.
username
}
"
}
before
do
before
do
issue
.
update
(
assignee_ids:
[
user
.
id
])
issue
.
update
!
(
assignee_ids:
[
user
.
id
])
end
end
context
'unlicensed'
do
context
'unlicensed'
do
...
@@ -296,6 +298,97 @@ describe QuickActions::InterpretService do
...
@@ -296,6 +298,97 @@ describe QuickActions::InterpretService do
end
end
end
end
end
end
shared_examples
'weight command'
do
it
'populates weight specified by the /weight command'
do
_
,
updates
=
service
.
execute
(
content
,
issuable
)
expect
(
updates
).
to
eq
(
weight:
weight
)
end
end
shared_examples
'clear weight command'
do
it
'populates weight: nil if content contains /clear_weight'
do
issuable
.
update!
(
weight:
5
)
_
,
updates
=
service
.
execute
(
content
,
issuable
)
expect
(
updates
).
to
eq
(
weight:
nil
)
end
end
context
'issuable weights licensed'
do
before
do
stub_licensed_features
(
issue_weights:
true
)
end
it_behaves_like
'weight command'
do
let
(
:weight
)
{
5
}
let
(
:content
)
{
"/weight
#{
weight
}
"
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'clear weight command'
do
let
(
:content
)
{
'/clear_weight'
}
let
(
:issuable
)
{
issue
}
end
end
context
'issuable weights unlicensed'
do
before
do
stub_licensed_features
(
issue_weights:
false
)
end
it
'does not recognise /weight X'
do
_
,
updates
=
service
.
execute
(
'/weight 5'
,
issue
)
expect
(
updates
).
to
be_empty
end
it
'does not recognise /clear_weight'
do
_
,
updates
=
service
.
execute
(
'/clear_weight'
,
issue
)
expect
(
updates
).
to
be_empty
end
end
shared_examples
'empty command'
do
it
'populates {} if content contains an unsupported command'
do
_
,
updates
=
service
.
execute
(
content
,
issuable
)
expect
(
updates
).
to
be_empty
end
end
context
'not persisted merge request can not be merged'
do
it_behaves_like
'empty command'
do
let
(
:content
)
{
"/merge"
}
let
(
:issuable
)
{
build
(
:merge_request
,
source_project:
project
)
}
end
end
context
'not approved merge request can not be merged'
do
before
do
merge_request
.
target_project
.
update!
(
approvals_before_merge:
1
)
end
it_behaves_like
'empty command'
do
let
(
:content
)
{
"/merge"
}
let
(
:issuable
)
{
build
(
:merge_request
,
source_project:
project
)
}
end
end
context
'approved merge request can be merged'
do
before
do
merge_request
.
update!
(
approvals_before_merge:
1
)
merge_request
.
approvals
.
create
(
user:
current_user
)
end
it_behaves_like
'empty command'
do
let
(
:content
)
{
"/merge"
}
let
(
:issuable
)
{
build
(
:merge_request
,
source_project:
project
)
}
end
end
end
end
describe
'#explain'
do
describe
'#explain'
do
...
@@ -331,5 +424,14 @@ describe QuickActions::InterpretService do
...
@@ -331,5 +424,14 @@ describe QuickActions::InterpretService do
expect
(
explanations
).
to
eq
([
"Removes assignee @
#{
user
.
username
}
."
])
expect
(
explanations
).
to
eq
([
"Removes assignee @
#{
user
.
username
}
."
])
end
end
end
end
describe
'weight command'
do
let
(
:content
)
{
'/weight 4'
}
it
'includes the number'
do
_
,
explanations
=
service
.
explain
(
content
,
issue
)
expect
(
explanations
).
to
eq
([
'Sets weight to 4.'
])
end
end
end
end
end
end
spec/services/notes/quick_actions_service_spec.rb
View file @
5d373fdd
...
@@ -171,7 +171,7 @@ describe Notes::QuickActionsService do
...
@@ -171,7 +171,7 @@ describe Notes::QuickActionsService do
end
end
end
end
context
'
I
ssue assignees'
do
context
'
CE restriction for i
ssue assignees'
do
describe
'/assign'
do
describe
'/assign'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:maintainer
)
{
create
(
:user
).
tap
{
|
u
|
project
.
add_maintainer
(
u
)
}
}
let
(
:maintainer
)
{
create
(
:user
).
tap
{
|
u
|
project
.
add_maintainer
(
u
)
}
}
...
@@ -185,6 +185,7 @@ describe Notes::QuickActionsService do
...
@@ -185,6 +185,7 @@ describe Notes::QuickActionsService do
end
end
before
do
before
do
stub_licensed_features
(
multiple_issue_assignees:
false
)
project
.
add_maintainer
(
maintainer
)
project
.
add_maintainer
(
maintainer
)
project
.
add_maintainer
(
assignee
)
project
.
add_maintainer
(
assignee
)
end
end
...
@@ -193,7 +194,7 @@ describe Notes::QuickActionsService do
...
@@ -193,7 +194,7 @@ describe Notes::QuickActionsService do
_
,
update_params
=
service
.
execute
(
note
)
_
,
update_params
=
service
.
execute
(
note
)
service
.
apply_updates
(
update_params
,
note
)
service
.
apply_updates
(
update_params
,
note
)
expect
(
note
.
noteable
.
assignees
.
count
).
to
eq
(
2
)
expect
(
note
.
noteable
.
assignees
.
count
).
to
eq
(
1
)
end
end
end
end
end
end
...
...
spec/services/quick_actions/interpret_service_spec.rb
View file @
5d373fdd
...
@@ -344,23 +344,6 @@ describe QuickActions::InterpretService do
...
@@ -344,23 +344,6 @@ describe QuickActions::InterpretService do
end
end
end
end
shared_examples
'weight command'
do
it
'populates weight: 5 if content contains /weight 5'
do
_
,
updates
=
service
.
execute
(
content
,
issuable
)
expect
(
updates
).
to
eq
(
weight:
5
)
end
end
shared_examples
'clear weight command'
do
it
'populates weight: nil if content contains /clear_weight'
do
issuable
.
update
(
weight:
5
)
_
,
updates
=
service
.
execute
(
content
,
issuable
)
expect
(
updates
).
to
eq
(
weight:
nil
)
end
end
shared_examples
'duplicate command'
do
shared_examples
'duplicate command'
do
it
'fetches issue and populates canonical_issue_id if content contains /duplicate issue_reference'
do
it
'fetches issue and populates canonical_issue_id if content contains /duplicate issue_reference'
do
issue_duplicate
# populate the issue
issue_duplicate
# populate the issue
...
@@ -504,29 +487,6 @@ describe QuickActions::InterpretService do
...
@@ -504,29 +487,6 @@ describe QuickActions::InterpretService do
let
(
:issuable
)
{
build
(
:merge_request
,
source_project:
project
)
}
let
(
:issuable
)
{
build
(
:merge_request
,
source_project:
project
)
}
end
end
end
end
context
'not approved merge request can not be merged'
do
before
do
merge_request
.
target_project
.
update
(
approvals_before_merge:
1
)
end
it_behaves_like
'empty command'
do
let
(
:content
)
{
"/merge"
}
let
(
:issuable
)
{
build
(
:merge_request
,
source_project:
project
)
}
end
end
context
'approved merge request can be merged'
do
before
do
merge_request
.
update
(
approvals_before_merge:
1
)
merge_request
.
approvals
.
create
(
user:
developer
)
end
it_behaves_like
'empty command'
do
let
(
:content
)
{
"/merge"
}
let
(
:issuable
)
{
build
(
:merge_request
,
source_project:
project
)
}
end
end
end
end
it_behaves_like
'title command'
do
it_behaves_like
'title command'
do
...
@@ -612,7 +572,7 @@ describe QuickActions::InterpretService do
...
@@ -612,7 +572,7 @@ describe QuickActions::InterpretService do
context
'Issue'
do
context
'Issue'
do
it
'populates assignee_ids: [] if content contains /unassign'
do
it
'populates assignee_ids: [] if content contains /unassign'
do
issue
.
update
(
assignee_ids:
[
developer
.
id
])
issue
.
update
!
(
assignee_ids:
[
developer
.
id
])
_
,
updates
=
service
.
execute
(
content
,
issue
)
_
,
updates
=
service
.
execute
(
content
,
issue
)
expect
(
updates
).
to
eq
(
assignee_ids:
[])
expect
(
updates
).
to
eq
(
assignee_ids:
[])
...
@@ -621,7 +581,7 @@ describe QuickActions::InterpretService do
...
@@ -621,7 +581,7 @@ describe QuickActions::InterpretService do
context
'Merge Request'
do
context
'Merge Request'
do
it
'populates assignee_ids: [] if content contains /unassign'
do
it
'populates assignee_ids: [] if content contains /unassign'
do
merge_request
.
update
(
assignee_ids:
[
developer
.
id
])
merge_request
.
update
!
(
assignee_ids:
[
developer
.
id
])
_
,
updates
=
service
.
execute
(
content
,
merge_request
)
_
,
updates
=
service
.
execute
(
content
,
merge_request
)
expect
(
updates
).
to
eq
(
assignee_ids:
[])
expect
(
updates
).
to
eq
(
assignee_ids:
[])
...
@@ -909,40 +869,6 @@ describe QuickActions::InterpretService do
...
@@ -909,40 +869,6 @@ describe QuickActions::InterpretService do
let
(
:issuable
)
{
merge_request
}
let
(
:issuable
)
{
merge_request
}
end
end
context
'issuable weights licensed'
do
before
do
stub_licensed_features
(
issue_weights:
true
)
end
it_behaves_like
'weight command'
do
let
(
:content
)
{
'/weight 5'
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'clear weight command'
do
let
(
:content
)
{
'/clear_weight'
}
let
(
:issuable
)
{
issue
}
end
end
context
'issuable weights unlicensed'
do
before
do
stub_licensed_features
(
issue_weights:
false
)
end
it
'does not recognise /weight X'
do
_
,
updates
=
service
.
execute
(
'/weight 5'
,
issue
)
expect
(
updates
).
to
be_empty
end
it
'does not recognise /clear_weight'
do
_
,
updates
=
service
.
execute
(
'/clear_weight'
,
issue
)
expect
(
updates
).
to
be_empty
end
end
context
'/todo'
do
context
'/todo'
do
let
(
:content
)
{
'/todo'
}
let
(
:content
)
{
'/todo'
}
...
@@ -1652,16 +1578,5 @@ describe QuickActions::InterpretService do
...
@@ -1652,16 +1578,5 @@ describe QuickActions::InterpretService do
expect
(
service
.
commands_executed_count
).
to
eq
(
3
)
expect
(
service
.
commands_executed_count
).
to
eq
(
3
)
end
end
end
end
# EE-specific tests
describe
'weight command'
do
let
(
:content
)
{
'/weight 4'
}
it
'includes the number'
do
_
,
explanations
=
service
.
explain
(
content
,
issue
)
expect
(
explanations
).
to
eq
([
'Sets weight to 4.'
])
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