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
7d38a023
Commit
7d38a023
authored
Feb 26, 2020
by
Christian Couder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for 'assign' push option
parent
d67bbfdc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
0 deletions
+77
-0
spec/services/merge_requests/push_options_handler_service_spec.rb
...vices/merge_requests/push_options_handler_service_spec.rb
+77
-0
No files found.
spec/services/merge_requests/push_options_handler_service_spec.rb
View file @
7d38a023
...
...
@@ -25,6 +25,10 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
let
(
:default_branch_changes
)
{
"d14d6c0abdd253381df51a723d58691b2ee1ab08 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/
#{
project
.
default_branch
}
"
}
let
(
:error_mr_required
)
{
"A merge_request.create push option is required to create a merge request for branch
#{
source_branch
}
"
}
before
do
stub_licensed_features
(
multiple_merge_request_assignees:
false
)
end
shared_examples_for
'a service that can create a merge request'
do
subject
(
:last_mr
)
{
MergeRequest
.
last
}
...
...
@@ -117,6 +121,17 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
end
end
# In the foss version of GitLab, there can be only one assignee
shared_examples_for
'a service that can change one assignee of a merge request'
do
subject
(
:last_mr
)
{
MergeRequest
.
last
}
it
'changes assignee count'
do
service
.
execute
expect
(
last_mr
.
assignees
.
count
).
to
eq
(
1
)
end
end
shared_examples_for
'a service that does not create a merge request'
do
it
do
expect
{
service
.
execute
}.
not_to
change
{
MergeRequest
.
count
}
...
...
@@ -603,6 +618,68 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
end
end
describe
'`assign` push option'
do
let
(
:push_options
)
{
{
assign:
{
user2
.
id
=>
1
,
user3
.
id
=>
1
}
}
}
context
'with a new branch'
do
let
(
:changes
)
{
new_branch_changes
}
it_behaves_like
'a service that does not create a merge request'
it
'adds an error to the service'
do
service
.
execute
expect
(
service
.
errors
).
to
include
(
error_mr_required
)
end
context
'when coupled with the `create` push option in foss'
do
let
(
:push_options
)
{
{
create:
true
,
assign:
{
user2
.
id
=>
1
,
user3
.
id
=>
1
}
}
}
it_behaves_like
'a service that can create a merge request'
it_behaves_like
'a service that can change one assignee of a merge request'
end
end
context
'with an existing branch but no open MR'
do
let
(
:changes
)
{
existing_branch_changes
}
it_behaves_like
'a service that does not create a merge request'
it
'adds an error to the service'
do
service
.
execute
expect
(
service
.
errors
).
to
include
(
error_mr_required
)
end
context
'when coupled with the `create` push option in foss'
do
let
(
:push_options
)
{
{
create:
true
,
assign:
{
user2
.
id
=>
1
,
user3
.
id
=>
1
}
}
}
it_behaves_like
'a service that can create a merge request'
it_behaves_like
'a service that can change one assignee of a merge request'
end
end
context
'with an existing branch that has a merge request open in foss'
do
let
(
:changes
)
{
existing_branch_changes
}
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
source_branch:
source_branch
)}
it_behaves_like
'a service that does not create a merge request'
it_behaves_like
'a service that can change one assignee of a merge request'
end
context
'with a deleted branch'
do
let
(
:changes
)
{
deleted_branch_changes
}
it_behaves_like
'a service that does nothing'
end
context
'with the project default branch'
do
let
(
:changes
)
{
default_branch_changes
}
it_behaves_like
'a service that does nothing'
end
end
describe
'multiple pushed branches'
do
let
(
:push_options
)
{
{
create:
true
}
}
let
(
:changes
)
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