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
iv
gitlab-ce
Commits
536373ad
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
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
17 deletions
+22
-17
app/views/projects/merge_requests/_new_compare.html.haml
app/views/projects/merge_requests/_new_compare.html.haml
+18
-3
features/project/forked_merge_requests.feature
features/project/forked_merge_requests.feature
+1
-2
features/steps/project/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 @@
...
@@ -2,11 +2,12 @@
%hr
%hr
=
form_for
[
@project
,
@merge_request
],
url:
new_project_merge_request_path
(
@project
),
method: :get
,
html:
{
class:
"merge-request-form form-inline"
}
do
|
f
|
=
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
.merge-request-branches.row
.col-md-6
.col-md-6
.panel.panel-default
.panel.panel-default
.panel-heading
.panel-heading
From
%strong
Source branch
.panel-body
.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?
})
=
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 @@
...
@@ -17,7 +18,7 @@
.col-md-6
.col-md-6
.panel.panel-default
.panel.panel-default
.panel-heading
.panel-heading
To
%strong
Target branch
.panel-body
.panel-body
-
projects
=
@project
.
forked_from_project
.
nil?
?
[
@project
]
:
[
@project
,
@project
.
forked_from_project
]
-
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?
})
=
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 @@
...
@@ -45,8 +46,9 @@
%span
.label-branch
#{
@merge_request
.
target_branch
}
%span
.label-branch
#{
@merge_request
.
target_branch
}
are the same.
are the same.
%hr
%hr
=
f
.
submit
'Compare branches'
,
class:
"btn btn-primary"
=
f
.
submit
'Compare branches'
,
class:
"btn btn-primary
mr-compare-btn
"
:javascript
:javascript
var
source_branch
=
$
(
"
#merge_request_source_branch
"
)
var
source_branch
=
$
(
"
#merge_request_source_branch
"
)
...
@@ -61,9 +63,22 @@
...
@@ -61,9 +63,22 @@
});
});
source_branch
.
on
(
"
change
"
,
function
()
{
source_branch
.
on
(
"
change
"
,
function
()
{
$
.
get
(
"
#{
branch_from_project_merge_requests_path
(
@source_project
)
}
"
,
{
ref
:
$
(
this
).
val
()
});
$
.
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
()
{
target_branch
.
on
(
"
change
"
,
function
()
{
$
.
get
(
"
#{
branch_to_project_merge_requests_path
(
@source_project
)
}
"
,
{
target_project_id
:
target_project
.
val
(),
ref
:
$
(
this
).
val
()
});
$
.
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,7 +30,6 @@ Feature: Project Forked Merge Requests
...
@@ -30,7 +30,6 @@ Feature: Project Forked Merge Requests
Given
I visit project
"Forked Shop"
merge requests page
Given
I visit project
"Forked Shop"
merge requests page
And
I click link
"New Merge Request"
And
I click link
"New Merge Request"
And
I fill out an invalid
"Merge Request On Forked Project"
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
Then
I should see validation errors
@javascript
@javascript
...
...
features/steps/project/forked_merge_requests.rb
View file @
536373ad
...
@@ -53,6 +53,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
...
@@ -53,6 +53,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
find
(
:select
,
"merge_request_source_branch"
,
{}).
value
.
should
==
'master'
find
(
:select
,
"merge_request_source_branch"
,
{}).
value
.
should
==
'master'
find
(
:select
,
"merge_request_target_branch"
,
{}).
value
.
should
==
'stable'
find
(
:select
,
"merge_request_target_branch"
,
{}).
value
.
should
==
'stable'
click_button
"Compare branches"
fill_in
"merge_request_title"
,
with:
"Merge Request On Forked Project"
fill_in
"merge_request_title"
,
with:
"Merge Request On Forked Project"
end
end
...
@@ -148,29 +149,19 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
...
@@ -148,29 +149,19 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
current_path
.
should
==
edit_project_merge_request_path
(
@project
,
@merge_request
)
current_path
.
should
==
edit_project_merge_request_path
(
@project
,
@merge_request
)
page
.
should
have_content
"Edit merge request #
#{
@merge_request
.
id
}
"
page
.
should
have_content
"Edit merge request #
#{
@merge_request
.
id
}
"
find
(
"#merge_request_title"
).
value
.
should
==
"Merge Request On Forked Project"
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
end
step
'I fill out an invalid "Merge Request On Forked Project" merge request'
do
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"
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_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_target_project_id"
,
{}).
value
.
should
==
project
.
id
.
to_s
find
(
:select
,
"merge_request_source_branch"
,
{}).
value
.
should
==
""
find
(
:select
,
"merge_request_source_branch"
,
{}).
value
.
should
==
""
find
(
:select
,
"merge_request_target_branch"
,
{}).
value
.
should
==
""
find
(
:select
,
"merge_request_target_branch"
,
{}).
value
.
should
==
""
click_button
"Compare branches"
end
end
step
'I should see validation errors'
do
step
'I should see validation errors'
do
page
.
should
have_content
"Source branch can't be blank"
page
.
should
have_content
"You must select source and target branch"
page
.
should
have_content
"Target branch can't be blank"
end
end
step
'the target repository should be the original repository'
do
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