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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
5ec780f4
Commit
5ec780f4
authored
Apr 03, 2019
by
Alexandru Croitor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract target branch quick action to shared example
parent
2fdc7c1f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
78 deletions
+78
-78
spec/features/merge_request/user_uses_quick_actions_spec.rb
spec/features/merge_request/user_uses_quick_actions_spec.rb
+1
-78
spec/support/shared_examples/quick_actions/merge_request/target_branch_quick_action_shared_examples.rb
...rge_request/target_branch_quick_action_shared_examples.rb
+77
-0
No files found.
spec/features/merge_request/user_uses_quick_actions_spec.rb
View file @
5ec780f4
...
@@ -57,6 +57,7 @@ describe 'Merge request > User uses quick actions', :js do
...
@@ -57,6 +57,7 @@ describe 'Merge request > User uses quick actions', :js do
end
end
it_behaves_like
'merge quick action'
it_behaves_like
'merge quick action'
it_behaves_like
'target_branch quick action'
describe
'toggling the WIP prefix in the title from note'
do
describe
'toggling the WIP prefix in the title from note'
do
context
'when the current user can toggle the WIP prefix'
do
context
'when the current user can toggle the WIP prefix'
do
...
@@ -104,83 +105,5 @@ describe 'Merge request > User uses quick actions', :js do
...
@@ -104,83 +105,5 @@ describe 'Merge request > User uses quick actions', :js do
end
end
end
end
end
end
describe
'/target_branch command in merge request'
do
let
(
:another_project
)
{
create
(
:project
,
:public
,
:repository
)
}
let
(
:new_url_opts
)
{
{
merge_request:
{
source_branch:
'feature'
}
}
}
before
do
another_project
.
add_maintainer
(
user
)
sign_in
(
user
)
end
it
'changes target_branch in new merge_request'
do
visit
project_new_merge_request_path
(
another_project
,
new_url_opts
)
fill_in
"merge_request_title"
,
with:
'My brand new feature'
fill_in
"merge_request_description"
,
with:
"le feature
\n
/target_branch fix
\n
Feature description:"
click_button
"Submit merge request"
merge_request
=
another_project
.
merge_requests
.
first
expect
(
merge_request
.
description
).
to
eq
"le feature
\n
Feature description:"
expect
(
merge_request
.
target_branch
).
to
eq
'fix'
end
it
'does not change target branch when merge request is edited'
do
new_merge_request
=
create
(
:merge_request
,
source_project:
another_project
)
visit
edit_project_merge_request_path
(
another_project
,
new_merge_request
)
fill_in
"merge_request_description"
,
with:
"Want to update target branch
\n
/target_branch fix
\n
"
click_button
"Save changes"
new_merge_request
=
another_project
.
merge_requests
.
first
expect
(
new_merge_request
.
description
).
to
include
(
'/target_branch'
)
expect
(
new_merge_request
.
target_branch
).
not_to
eq
(
'fix'
)
end
end
describe
'/target_branch command from note'
do
context
'when the current user can change target branch'
do
before
do
sign_in
(
user
)
visit
project_merge_request_path
(
project
,
merge_request
)
end
it
'changes target branch from a note'
do
add_note
(
"message start
\n
/target_branch merge-test
\n
message end."
)
wait_for_requests
expect
(
page
).
not_to
have_content
(
'/target_branch'
)
expect
(
page
).
to
have_content
(
'message start'
)
expect
(
page
).
to
have_content
(
'message end.'
)
expect
(
merge_request
.
reload
.
target_branch
).
to
eq
'merge-test'
end
it
'does not fail when target branch does not exists'
do
add_note
(
'/target_branch totally_not_existing_branch'
)
expect
(
page
).
not_to
have_content
(
'/target_branch'
)
expect
(
merge_request
.
target_branch
).
to
eq
'feature'
end
end
context
'when current user can not change target branch'
do
before
do
project
.
add_guest
(
guest
)
sign_in
(
guest
)
visit
project_merge_request_path
(
project
,
merge_request
)
end
it
'does not change target branch'
do
add_note
(
'/target_branch merge-test'
)
expect
(
page
).
not_to
have_content
'/target_branch merge-test'
expect
(
merge_request
.
target_branch
).
to
eq
'feature'
end
end
end
end
end
end
end
spec/support/shared_examples/quick_actions/merge_request/target_branch_quick_action_shared_examples.rb
View file @
5ec780f4
# frozen_string_literal: true
# frozen_string_literal: true
shared_examples
'target_branch quick action'
do
shared_examples
'target_branch quick action'
do
describe
'/target_branch command in merge request'
do
let
(
:another_project
)
{
create
(
:project
,
:public
,
:repository
)
}
let
(
:new_url_opts
)
{
{
merge_request:
{
source_branch:
'feature'
}
}
}
before
do
another_project
.
add_maintainer
(
user
)
sign_in
(
user
)
end
it
'changes target_branch in new merge_request'
do
visit
project_new_merge_request_path
(
another_project
,
new_url_opts
)
fill_in
"merge_request_title"
,
with:
'My brand new feature'
fill_in
"merge_request_description"
,
with:
"le feature
\n
/target_branch fix
\n
Feature description:"
click_button
"Submit merge request"
merge_request
=
another_project
.
merge_requests
.
first
expect
(
merge_request
.
description
).
to
eq
"le feature
\n
Feature description:"
expect
(
merge_request
.
target_branch
).
to
eq
'fix'
end
it
'does not change target branch when merge request is edited'
do
new_merge_request
=
create
(
:merge_request
,
source_project:
another_project
)
visit
edit_project_merge_request_path
(
another_project
,
new_merge_request
)
fill_in
"merge_request_description"
,
with:
"Want to update target branch
\n
/target_branch fix
\n
"
click_button
"Save changes"
new_merge_request
=
another_project
.
merge_requests
.
first
expect
(
new_merge_request
.
description
).
to
include
(
'/target_branch'
)
expect
(
new_merge_request
.
target_branch
).
not_to
eq
(
'fix'
)
end
end
describe
'/target_branch command from note'
do
context
'when the current user can change target branch'
do
before
do
sign_in
(
user
)
visit
project_merge_request_path
(
project
,
merge_request
)
end
it
'changes target branch from a note'
do
add_note
(
"message start
\n
/target_branch merge-test
\n
message end."
)
wait_for_requests
expect
(
page
).
not_to
have_content
(
'/target_branch'
)
expect
(
page
).
to
have_content
(
'message start'
)
expect
(
page
).
to
have_content
(
'message end.'
)
expect
(
merge_request
.
reload
.
target_branch
).
to
eq
'merge-test'
end
it
'does not fail when target branch does not exists'
do
add_note
(
'/target_branch totally_not_existing_branch'
)
expect
(
page
).
not_to
have_content
(
'/target_branch'
)
expect
(
merge_request
.
target_branch
).
to
eq
'feature'
end
end
context
'when current user can not change target branch'
do
before
do
project
.
add_guest
(
guest
)
sign_in
(
guest
)
visit
project_merge_request_path
(
project
,
merge_request
)
end
it
'does not change target branch'
do
add_note
(
'/target_branch merge-test'
)
expect
(
page
).
not_to
have_content
'/target_branch merge-test'
expect
(
merge_request
.
target_branch
).
to
eq
'feature'
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