BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
536373ad
Unverified
Commit
536373ad
authored
May 08, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dont allow mr compare with empty branches
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
86bf684f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
18 deletions
+22
-18
_new_compare.html.haml
app/views/projects/merge_requests/_new_compare.html.haml
+18
-3
forked_merge_requests.feature
features/project/forked_merge_requests.feature
+1
-3
forked_merge_requests.rb
features/steps/project/forked_merge_requests.rb
+3
-12
No files found.
app/views/projects/merge_requests/_new_compare.html.haml
View file @
536373ad
...
...
@@ -2,11 +2,12 @@
%hr
=
form_for
[
@project
,
@merge_request
],
url:
new_project_merge_request_path
(
@project
),
method: :get
,
html:
{
class:
"merge-request-form form-inline"
}
do
|
f
|
.hide.alert.alert-danger.mr-compare-errors
.merge-request-branches.row
.col-md-6
.panel.panel-default
.panel-heading
From
%strong
Source branch
.panel-body
=
f
.
select
(
:source_project_id
,
[[
@merge_request
.
source_project_path
,
@merge_request
.
source_project
.
id
]]
,
{},
{
class:
'source_project select2 span3'
,
disabled:
@merge_request
.
persisted?
})
...
...
@@ -17,7 +18,7 @@
.col-md-6
.panel.panel-default
.panel-heading
To
%strong
Target branch
.panel-body
-
projects
=
@project
.
forked_from_project
.
nil?
?
[
@project
]
:
[
@project
,
@project
.
forked_from_project
]
=
f
.
select
(
:target_project_id
,
options_from_collection_for_select
(
projects
,
'id'
,
'path_with_namespace'
,
f
.
object
.
target_project_id
),
{},
{
class:
'target_project select2 span3'
,
disabled:
@merge_request
.
persisted?
})
...
...
@@ -45,8 +46,9 @@
%span
.label-branch
#{
@merge_request
.
target_branch
}
are the same.
%hr
=
f
.
submit
'Compare branches'
,
class:
"btn btn-primary"
=
f
.
submit
'Compare branches'
,
class:
"btn btn-primary
mr-compare-btn
"
:javascript
var
source_branch
=
$
(
"#merge_request_source_branch"
)
...
...
@@ -61,9 +63,22 @@
});
source_branch
.
on
(
"change"
,
function
()
{
$
.
get
(
"
#{
branch_from_project_merge_requests_path
(
@source_project
)
}
"
,
{
ref
:
$
(
this
).
val
()
});
$
(
".mr-compare-errors"
).
fadeOut
();
$
(
".mr-compare-btn"
).
enable
();
});
target_branch
.
on
(
"change"
,
function
()
{
$
.
get
(
"
#{
branch_to_project_merge_requests_path
(
@source_project
)
}
"
,
{
target_project_id
:
target_project
.
val
(),
ref
:
$
(
this
).
val
()
});
$
(
".mr-compare-errors"
).
fadeOut
();
$
(
".mr-compare-btn"
).
enable
();
});
:coffeescript
$(".merge-request-form").on 'submit', ->
if $("#merge_request_source_branch").val() is "" or $('#merge_request_target_branch').val() is ""
$(".mr-compare-errors").html("You must select source and target branch to proceed")
$(".mr-compare-errors").fadeIn()
event.preventDefault()
return
features/project/forked_merge_requests.feature
View file @
536373ad
...
...
@@ -30,11 +30,10 @@ Feature: Project Forked Merge Requests
Given
I visit project
"Forked Shop"
merge requests page
And
I click link
"New Merge Request"
And
I fill out an invalid
"Merge Request On Forked Project"
merge request
And
I submit the merge request
Then
I should see validation errors
@javascript
Scenario
:
Merge request should target fork repository by default
Given
I visit project
"Forked Shop"
merge requests page
And
I click link
"New Merge Request"
Then
the target repository should be the original repository
\ No newline at end of file
Then
the target repository should be the original repository
features/steps/project/forked_merge_requests.rb
View file @
536373ad
...
...
@@ -53,6 +53,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
find
(
:select
,
"merge_request_source_branch"
,
{}).
value
.
should
==
'master'
find
(
:select
,
"merge_request_target_branch"
,
{}).
value
.
should
==
'stable'
click_button
"Compare branches"
fill_in
"merge_request_title"
,
with:
"Merge Request On Forked Project"
end
...
...
@@ -148,29 +149,19 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
current_path
.
should
==
edit_project_merge_request_path
(
@project
,
@merge_request
)
page
.
should
have_content
"Edit merge request #
#{
@merge_request
.
id
}
"
find
(
"#merge_request_title"
).
value
.
should
==
"Merge Request On Forked Project"
find
(
"#merge_request_source_project_id"
).
value
.
should
==
@forked_project
.
id
.
to_s
find
(
"#merge_request_target_project_id"
).
value
.
should
==
@project
.
id
.
to_s
find
(
"#merge_request_source_branch"
).
value
.
should
have_content
"master"
verify_commit_link
(
".mr_source_commit"
,
@forked_project
)
find
(
"#merge_request_target_branch"
).
value
.
should
have_content
"stable"
verify_commit_link
(
".mr_target_commit"
,
@project
)
end
step
'I fill out an invalid "Merge Request On Forked Project" merge request'
do
#If this isn't filled in the rest of the validations won't be triggered
fill_in
"merge_request_title"
,
with:
"Merge Request On Forked Project"
select
"Select branch"
,
from:
"merge_request_target_branch"
find
(
:select
,
"merge_request_source_project_id"
,
{}).
value
.
should
==
@forked_project
.
id
.
to_s
find
(
:select
,
"merge_request_target_project_id"
,
{}).
value
.
should
==
project
.
id
.
to_s
find
(
:select
,
"merge_request_source_branch"
,
{}).
value
.
should
==
""
find
(
:select
,
"merge_request_target_branch"
,
{}).
value
.
should
==
""
click_button
"Compare branches"
end
step
'I should see validation errors'
do
page
.
should
have_content
"Source branch can't be blank"
page
.
should
have_content
"Target branch can't be blank"
page
.
should
have_content
"You must select source and target branch"
end
step
'the target repository should be the original repository'
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