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
Kazuhiko Shiozaki
gitlab-ce
Commits
22ac0cc7
Commit
22ac0cc7
authored
Nov 28, 2011
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/merge_requests'
parents
7002b9ff
e74ec3c9
Changes
29
Show whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
531 additions
and
42 deletions
+531
-42
app/assets/javascripts/merge_requests.js.coffee
app/assets/javascripts/merge_requests.js.coffee
+3
-0
app/assets/stylesheets/application.css
app/assets/stylesheets/application.css
+1
-0
app/assets/stylesheets/issues.css.scss
app/assets/stylesheets/issues.css.scss
+2
-0
app/assets/stylesheets/merge_requests.css.scss
app/assets/stylesheets/merge_requests.css.scss
+10
-0
app/assets/stylesheets/projects.css.scss
app/assets/stylesheets/projects.css.scss
+75
-2
app/controllers/merge_requests_controller.rb
app/controllers/merge_requests_controller.rb
+90
-0
app/controllers/notes_controller.rb
app/controllers/notes_controller.rb
+2
-0
app/helpers/merge_requests_helper.rb
app/helpers/merge_requests_helper.rb
+2
-0
app/models/ability.rb
app/models/ability.rb
+4
-1
app/models/merge_request.rb
app/models/merge_request.rb
+36
-0
app/models/project.rb
app/models/project.rb
+1
-0
app/views/issues/show.html.haml
app/views/issues/show.html.haml
+3
-3
app/views/layouts/project.html.haml
app/views/layouts/project.html.haml
+4
-0
app/views/merge_requests/_commits.html.haml
app/views/merge_requests/_commits.html.haml
+17
-0
app/views/merge_requests/_diffs.html.haml
app/views/merge_requests/_diffs.html.haml
+22
-0
app/views/merge_requests/_form.html.haml
app/views/merge_requests/_form.html.haml
+39
-0
app/views/merge_requests/_merge_request.html.haml
app/views/merge_requests/_merge_request.html.haml
+14
-0
app/views/merge_requests/edit.html.haml
app/views/merge_requests/edit.html.haml
+1
-0
app/views/merge_requests/index.html.haml
app/views/merge_requests/index.html.haml
+20
-0
app/views/merge_requests/new.html.haml
app/views/merge_requests/new.html.haml
+1
-0
app/views/merge_requests/show.html.haml
app/views/merge_requests/show.html.haml
+59
-0
config/routes.rb
config/routes.rb
+6
-0
db/migrate/20111127155345_create_merge_requests.rb
db/migrate/20111127155345_create_merge_requests.rb
+15
-0
db/schema.rb
db/schema.rb
+15
-1
spec/factories.rb
spec/factories.rb
+6
-0
spec/helpers/application_helper_spec.rb
spec/helpers/application_helper_spec.rb
+0
-35
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+5
-0
spec/requests/merge_requests_spec.rb
spec/requests/merge_requests_spec.rb
+69
-0
spec/requests/projects_security_spec.rb
spec/requests/projects_security_spec.rb
+9
-0
No files found.
app/assets/javascripts/merge_requests.js.coffee
0 → 100644
View file @
22ac0cc7
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
app/assets/stylesheets/application.css
View file @
22ac0cc7
...
@@ -49,3 +49,4 @@
...
@@ -49,3 +49,4 @@
.no-padding
{
.no-padding
{
padding
:
0
!important
;
padding
:
0
!important
;
}
}
app/assets/stylesheets/issues.css.scss
View file @
22ac0cc7
...
@@ -58,6 +58,8 @@
...
@@ -58,6 +58,8 @@
padding
:
0
;
padding
:
0
;
}
}
body
.project-page
.merge-request-form-holder
table
.no-borders
tr
,
body
.project-page
.merge-request-form-holder
table
.no-borders
td
,
body
.project-page
.issue-form-holder
table
.no-borders
tr
,
body
.project-page
.issue-form-holder
table
.no-borders
tr
,
body
.project-page
.issue-form-holder
table
.no-borders
td
,
body
.project-page
.issue-form-holder
table
.no-borders
td
,
body
.project-page
.new_snippet
table
tr
,
body
.project-page
.new_snippet
table
tr
,
...
...
app/assets/stylesheets/merge_requests.css.scss
0 → 100644
View file @
22ac0cc7
// Place all the styles related to the MergeRequests controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
.merge-request-form-holder
{
select
{
width
:
300px
;
}
}
app/assets/stylesheets/projects.css.scss
View file @
22ac0cc7
...
@@ -155,6 +155,8 @@ input.ssh_project_url {
...
@@ -155,6 +155,8 @@ input.ssh_project_url {
}
}
/** FORM INPUTS **/
/** FORM INPUTS **/
.new_merge_request
,
.edit_merge_request
,
.user_new
,
.user_new
,
.new_key
,
.new_key
,
.new_issue
,
.new_issue
,
...
@@ -326,12 +328,16 @@ body.project-page table .commit {
...
@@ -326,12 +328,16 @@ body.project-page table .commit {
border
:none
;
border
:none
;
text-shadow
:none
;
text-shadow
:none
;
&
.high
{
&
.inline
{
display
:inline
;
}
&
.high
,
&
.closed
{
background
:
#D12F19
;
background
:
#D12F19
;
color
:white
;
color
:white
;
}
}
&
.today
{
&
.today
,
&
.open
{
background
:
#44aa22
;
background
:
#44aa22
;
color
:white
;
color
:white
;
}
}
...
@@ -384,6 +390,32 @@ body.dashboard.project-page .news-feed .project-updates a.project-update span.up
...
@@ -384,6 +390,32 @@ body.dashboard.project-page .news-feed .project-updates a.project-update span.up
body
.dashboard.project-page
.news-feed
.project-updates
a
.project-update
span
.update-author
strong
{
font-weight
:
bold
;
font-style
:
normal
;}
body
.dashboard.project-page
.news-feed
.project-updates
a
.project-update
span
.update-author
strong
{
font-weight
:
bold
;
font-style
:
normal
;}
/* eo Dashboard Page */
/* eo Dashboard Page */
/** Merge requests */
body
.project-page
.merge-request-commits
{
margin-bottom
:
20px
;
display
:
block
;
width
:
100%
;}
body
.project-page
.merge-request-commits
.data
{
padding
:
0
}
body
.project-page
.merge-request-commits
a
.commit
{
padding
:
10px
;
border-bottom
:
1px
solid
#eee
;
overflow
:
hidden
;
display
:
block
;}
body
.project-page
.merge-request-commits
a
.commit
:last-child
{
border-bottom
:
0
}
body
.project-page
.merge-request-commits
a
.commit
img
{
float
:
left
;
margin-right
:
10px
;}
body
.project-page
.merge-request-commits
a
.commit
span
.update-title
,
.dashboard-page
.news-feed
.project-updates
li
a
span
.update-author
{
display
:
block
;}
body
.project-page
.merge-request-commits
a
.commit
span
.update-title
{
margin-bottom
:
10px
}
body
.project-page
.merge-request-commits
a
.commit
span
.update-author
{
color
:
#999
;
font-weight
:
normal
;
font-style
:
italic
;}
body
.project-page
.merge-request-commits
a
.commit
span
.update-author
strong
{
font-weight
:
bold
;
font-style
:
normal
;}
/** Update entry **/
.update-data
{
padding
:
0
}
.update-data
{
width
:
100%
;
}
.update-data.ui-box
.data
{
padding
:
0
;
}
a
.update-item
{
padding
:
10px
;
border-bottom
:
1px
solid
#eee
;
overflow
:
hidden
;
display
:
block
;}
a
.update-item
:last-child
{
border-bottom
:
0
}
a
.update-item
img
{
float
:
left
;
margin-right
:
10px
;}
a
.update-item
span
.update-title
,
.dashboard-page
.news-feed
.project-updates
li
a
span
.update-author
{
display
:
block
;}
a
.update-item
span
.update-title
{
margin-bottom
:
10px
}
a
.update-item
span
.update-author
{
color
:
#999
;
font-weight
:
normal
;
font-style
:
italic
;}
a
.update-item
span
.update-author
strong
{
font-weight
:
bold
;
font-style
:
normal
;}
body
.project-page
.team_member_new
.span-6
,
.team_member_edit
.span-6
{
padding
:
10px
0
;
}
body
.project-page
.team_member_new
.span-6
,
.team_member_edit
.span-6
{
padding
:
10px
0
;
}
body
.projects-page
input
.text.git-url.project_list_url
{
width
:
165px
;
}
body
.projects-page
input
.text.git-url.project_list_url
{
width
:
165px
;
}
...
@@ -394,3 +426,44 @@ body.project-page table.no-borders tr,
...
@@ -394,3 +426,44 @@ body.project-page table.no-borders tr,
body
.project-page
table
.no-borders
td
{
body
.project-page
table
.no-borders
td
{
border
:none
;
border
:none
;
}
}
#gitlab-tabs
{
.ui-tabs-nav
{
border-bottom
:
1px
solid
#DEDFE1
;
li
{
background
:
none
;
border
:none
;
font-size
:
16px
;
margin
:
0
;
padding
:
0
;
a
{
margin
:
0
;
padding
:
10px
16px
;
width
:
150px
;
}
&
.ui-tabs-selected
{
background-image
:
-webkit-gradient
(
linear
,
0
0
,
0
26
,
color-stop
(
0
.076
,
#fefefe
)
,
to
(
#F6F7F8
));
background-image
:
-webkit-linear-gradient
(
#fefefe
7
.6%
,
#F6F7F8
);
background-image
:
-moz-linear-gradient
(
#fefefe
7
.6%
,
#F6F7F8
);
background-image
:
-o-linear-gradient
(
#fefefe
7
.6%
,
#F6F7F8
);
font-weight
:
bold
;
border
:
1px
solid
#DEDFE1
;
border-bottom
:
1px
solid
#DEDFE1
;
-webkit-border-top-left-radius
:
5px
;
-webkit-border-top-right-radius
:
5px
;
-moz-border-radius-topleft
:
5px
;
-moz-border-radius-topright
:
5px
;
border-top-left-radius
:
5px
;
border-top-right-radius
:
5px
;
}
}
}
}
.ajax-tab-loading
{
padding
:
40px
;
display
:none
;
}
app/controllers/merge_requests_controller.rb
0 → 100644
View file @
22ac0cc7
class
MergeRequestsController
<
ApplicationController
before_filter
:authenticate_user!
before_filter
:project
before_filter
:merge_request
,
:only
=>
[
:edit
,
:update
,
:destroy
,
:show
,
:commits
,
:diffs
]
layout
"project"
# Authorize
before_filter
:add_project_abilities
before_filter
:authorize_read_project!
before_filter
:authorize_write_project!
,
:only
=>
[
:new
,
:create
,
:edit
,
:update
]
def
index
@merge_requests
=
@project
.
merge_requests
end
def
show
unless
@project
.
repo
.
heads
.
map
(
&
:name
).
include?
(
@merge_request
.
target_branch
)
&&
@project
.
repo
.
heads
.
map
(
&
:name
).
include?
(
@merge_request
.
source_branch
)
head
(
404
)
and
return
end
@notes
=
@merge_request
.
notes
.
inc_author
.
order
(
"created_at DESC"
).
limit
(
20
)
@note
=
@project
.
notes
.
new
(
:noteable
=>
@merge_request
)
respond_to
do
|
format
|
format
.
html
format
.
js
{
respond_with_notes
}
end
end
def
commits
@commits
=
@project
.
repo
.
commits_between
(
@merge_request
.
target_branch
,
@merge_request
.
source_branch
).
map
{
|
c
|
Commit
.
new
(
c
)}
render
:template
=>
"merge_requests/_commits"
,
:layout
=>
false
end
def
diffs
@commit
=
@project
.
commit
(
@merge_request
.
source_branch
)
@diffs
=
@project
.
repo
.
diff
(
@merge_request
.
target_branch
,
@merge_request
.
source_branch
)
render
:template
=>
"merge_requests/_diffs"
,
:layout
=>
false
end
def
new
@merge_request
=
@project
.
merge_requests
.
new
end
def
edit
end
def
create
@merge_request
=
@project
.
merge_requests
.
new
(
params
[
:merge_request
])
@merge_request
.
author
=
current_user
respond_to
do
|
format
|
if
@merge_request
.
save
format
.
html
{
redirect_to
[
@project
,
@merge_request
],
notice:
'Merge request was successfully created.'
}
format
.
json
{
render
json:
@merge_request
,
status: :created
,
location:
@merge_request
}
else
format
.
html
{
render
action:
"new"
}
format
.
json
{
render
json:
@merge_request
.
errors
,
status: :unprocessable_entity
}
end
end
end
def
update
respond_to
do
|
format
|
if
@merge_request
.
update_attributes
(
params
[
:merge_request
])
format
.
html
{
redirect_to
[
@project
,
@merge_request
],
notice:
'Merge request was successfully updated.'
}
format
.
json
{
head
:ok
}
else
format
.
html
{
render
action:
"edit"
}
format
.
json
{
render
json:
@merge_request
.
errors
,
status: :unprocessable_entity
}
end
end
end
def
destroy
@merge_request
.
destroy
respond_to
do
|
format
|
format
.
html
{
redirect_to
project_merge_requests_url
(
@project
)
}
format
.
json
{
head
:ok
}
end
end
protected
def
merge_request
@merge_request
||=
@project
.
merge_requests
.
find
(
params
[
:id
])
end
end
app/controllers/notes_controller.rb
View file @
22ac0cc7
...
@@ -42,6 +42,8 @@ class NotesController < ApplicationController
...
@@ -42,6 +42,8 @@ class NotesController < ApplicationController
Notify
.
note_commit_email
(
u
,
@note
).
deliver
Notify
.
note_commit_email
(
u
,
@note
).
deliver
when
"Issue"
then
when
"Issue"
then
Notify
.
note_issue_email
(
u
,
@note
).
deliver
Notify
.
note_issue_email
(
u
,
@note
).
deliver
when
"MergeRequest"
true
# someone should write email notification
when
"Snippet"
when
"Snippet"
true
true
else
else
...
...
app/helpers/merge_requests_helper.rb
0 → 100644
View file @
22ac0cc7
module
MergeRequestsHelper
end
app/models/ability.rb
View file @
22ac0cc7
...
@@ -17,6 +17,7 @@ class Ability
...
@@ -17,6 +17,7 @@ class Ability
:read_issue
,
:read_issue
,
:read_snippet
,
:read_snippet
,
:read_team_member
,
:read_team_member
,
:read_merge_request
,
:read_note
:read_note
]
if
project
.
readers
.
include?
(
user
)
]
if
project
.
readers
.
include?
(
user
)
...
@@ -24,6 +25,7 @@ class Ability
...
@@ -24,6 +25,7 @@ class Ability
:write_project
,
:write_project
,
:write_issue
,
:write_issue
,
:write_snippet
,
:write_snippet
,
:write_merge_request
,
:write_note
:write_note
]
if
project
.
writers
.
include?
(
user
)
]
if
project
.
writers
.
include?
(
user
)
...
@@ -32,6 +34,7 @@ class Ability
...
@@ -32,6 +34,7 @@ class Ability
:admin_issue
,
:admin_issue
,
:admin_snippet
,
:admin_snippet
,
:admin_team_member
,
:admin_team_member
,
:admin_merge_request
,
:admin_note
:admin_note
]
if
project
.
admins
.
include?
(
user
)
]
if
project
.
admins
.
include?
(
user
)
...
@@ -39,7 +42,7 @@ class Ability
...
@@ -39,7 +42,7 @@ class Ability
end
end
class
<<
self
class
<<
self
[
:issue
,
:note
,
:snippet
].
each
do
|
name
|
[
:issue
,
:note
,
:snippet
,
:merge_request
].
each
do
|
name
|
define_method
"
#{
name
}
_abilities"
do
|
user
,
subject
|
define_method
"
#{
name
}
_abilities"
do
|
user
,
subject
|
if
subject
.
author
==
user
if
subject
.
author
==
user
[
[
...
...
app/models/merge_request.rb
0 → 100644
View file @
22ac0cc7
class
MergeRequest
<
ActiveRecord
::
Base
belongs_to
:project
belongs_to
:author
,
:class_name
=>
"User"
belongs_to
:assignee
,
:class_name
=>
"User"
has_many
:notes
,
:as
=>
:noteable
attr_protected
:author
,
:author_id
,
:project
,
:project_id
validates_presence_of
:project_id
validates_presence_of
:assignee_id
validates_presence_of
:author_id
validates_presence_of
:source_branch
validates_presence_of
:target_branch
delegate
:name
,
:email
,
:to
=>
:author
,
:prefix
=>
true
delegate
:name
,
:email
,
:to
=>
:assignee
,
:prefix
=>
true
validates
:title
,
:presence
=>
true
,
:length
=>
{
:within
=>
0
..
255
}
scope
:opened
,
where
(
:closed
=>
false
)
scope
:closed
,
where
(
:closed
=>
true
)
scope
:assigned
,
lambda
{
|
u
|
where
(
:assignee_id
=>
u
.
id
)}
def
new?
today?
&&
created_at
==
updated_at
end
end
app/models/project.rb
View file @
22ac0cc7
...
@@ -3,6 +3,7 @@ require "grit"
...
@@ -3,6 +3,7 @@ require "grit"
class
Project
<
ActiveRecord
::
Base
class
Project
<
ActiveRecord
::
Base
belongs_to
:owner
,
:class_name
=>
"User"
belongs_to
:owner
,
:class_name
=>
"User"
has_many
:merge_requests
,
:dependent
=>
:destroy
has_many
:issues
,
:dependent
=>
:destroy
,
:order
=>
"position"
has_many
:issues
,
:dependent
=>
:destroy
,
:order
=>
"position"
has_many
:users_projects
,
:dependent
=>
:destroy
has_many
:users_projects
,
:dependent
=>
:destroy
has_many
:users
,
:through
=>
:users_projects
has_many
:users
,
:through
=>
:users_projects
...
...
app/views/issues/show.html.haml
View file @
22ac0cc7
...
@@ -3,9 +3,9 @@
...
@@ -3,9 +3,9 @@
=
"Issue #
#{
@issue
.
id
}
"
=
"Issue #
#{
@issue
.
id
}
"
.right
.right
-
if
@issue
.
closed
-
if
@issue
.
closed
%span
.tag.
high
Resolv
ed
%span
.tag.
closed
Clos
ed
-
else
-
else
%span
.tag.
today
Open
%span
.tag.
open
Open
.data
.data
%p
=
@issue
.
title
%p
=
@issue
.
title
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
-
if
@issue
.
closed
-
if
@issue
.
closed
=
link_to
'Reopen'
,
project_issue_path
(
@project
,
@issue
,
:issue
=>
{
:closed
=>
false
},
:status_only
=>
true
),
:method
=>
:put
,
:class
=>
"grey-button"
=
link_to
'Reopen'
,
project_issue_path
(
@project
,
@issue
,
:issue
=>
{
:closed
=>
false
},
:status_only
=>
true
),
:method
=>
:put
,
:class
=>
"grey-button"
-
else
-
else
=
link_to
'
Resolv
e'
,
project_issue_path
(
@project
,
@issue
,
:issue
=>
{
:closed
=>
true
},
:status_only
=>
true
),
:method
=>
:put
,
:class
=>
"grey-button"
=
link_to
'
Clos
e'
,
project_issue_path
(
@project
,
@issue
,
:issue
=>
{
:closed
=>
true
},
:status_only
=>
true
),
:method
=>
:put
,
:class
=>
"grey-button"
.right
.right
=
link_to
'Edit'
,
edit_project_issue_path
(
@project
,
@issue
),
:class
=>
"grey-button positive"
=
link_to
'Edit'
,
edit_project_issue_path
(
@project
,
@issue
),
:class
=>
"grey-button positive"
...
...
app/views/layouts/project.html.haml
View file @
22ac0cc7
...
@@ -39,6 +39,10 @@
...
@@ -39,6 +39,10 @@
Wall
Wall
-
if
@project
.
common_notes
.
today
.
count
>
0
-
if
@project
.
common_notes
.
today
.
count
>
0
%span
{
:class
=>
"number"
}=
@project
.
common_notes
.
today
.
count
%span
{
:class
=>
"number"
}=
@project
.
common_notes
.
today
.
count
=
link_to
project_merge_requests_path
(
@project
),
:class
=>
(
controller
.
controller_name
==
"merge_requests"
)
?
"current"
:
nil
do
Merge Requests
-
if
@project
.
merge_requests
.
opened
.
count
>
0
%span
{
:class
=>
"number"
}=
@project
.
merge_requests
.
opened
.
count
=
link_to
project_snippets_path
(
@project
),
:class
=>
(
controller
.
controller_name
==
"snippets"
)
?
"current"
:
nil
do
=
link_to
project_snippets_path
(
@project
),
:class
=>
(
controller
.
controller_name
==
"snippets"
)
?
"current"
:
nil
do
Snippets
Snippets
-
if
@project
.
snippets
.
non_expired
.
count
>
0
-
if
@project
.
snippets
.
non_expired
.
count
>
0
...
...
app/views/merge_requests/_commits.html.haml
0 → 100644
View file @
22ac0cc7
-
if
@commits
.
size
>
0
.merge-request-commits.ui-box.width-100p
-
@commits
.
each
do
|
commit
|
%a
{
:class
=>
"commit"
,
:href
=>
project_commit_path
(
@project
,
:id
=>
commit
.
id
)
}
-
if
commit
.
author_email
=
image_tag
gravatar_icon
(
commit
.
author_email
),
:class
=>
"left"
,
:width
=>
40
,
:style
=>
"padding-right:5px;"
-
else
=
image_tag
"no_avatar.png"
,
:class
=>
"left"
,
:width
=>
40
,
:style
=>
"padding-right:5px;"
%span
.update-title
=
truncate
commit
.
safe_message
,
:length
=>
60
%span
.update-author
%strong
=
commit
.
author_name
authored
=
time_ago_in_words
(
commit
.
created_at
)
ago
.clear
app/views/merge_requests/_diffs.html.haml
0 → 100644
View file @
22ac0cc7
-
@diffs
.
each
do
|
diff
|
-
next
if
diff
.
diff
.
empty?
-
file
=
(
@commit
.
tree
/
diff
.
b_path
)
-
next
unless
file
.diff_file
.diff_file_header
-
if
diff
.
deleted_file
%strong
{
:id
=>
"#{diff.b_path}"
}=
diff
.
a_path
-
else
=
link_to
tree_file_project_ref_path
(
@project
,
@commit
.
id
,
diff
.
b_path
)
do
%strong
{
:id
=>
"#{diff.b_path}"
}=
diff
.
b_path
%br
/
.diff_file_content
-
if
file
.
text?
=
render
:partial
=>
"commits/text_file"
,
:locals
=>
{
:diff
=>
diff
}
-
elsif
file
.
image?
.diff_file_content_image
%img
{
:src
=>
"data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"
}
-
else
%p
%center
No preview for this file type
app/views/merge_requests/_form.html.haml
0 → 100644
View file @
22ac0cc7
%div
.merge-request-form-holder
.ui-box.width-100p
%h3
=
@merge_request
.
new_record?
?
"New Merge Request"
:
"Edit Merge Request #
#{
@merge_request
.
id
}
"
=
form_for
[
@project
,
@merge_request
]
do
|
f
|
.data
%table
.no-borders
-
if
@merge_request
.
errors
.
any?
%tr
%td
Errors
%td
#error_explanation
-
@merge_request
.
errors
.
full_messages
.
each
do
|
msg
|
%span
=
msg
%br
%tr
%td
=
f
.
label
:title
%td
=
f
.
text_field
:title
%tr
%td
=
f
.
label
:source_branch
,
"From"
%td
=
f
.
select
(
:source_branch
,
@project
.
heads
.
map
(
&
:name
),
{
:include_blank
=>
"Select branch"
})
%tr
%td
=
f
.
label
:target_branch
,
"To"
%td
=
f
.
select
(
:target_branch
,
@project
.
heads
.
map
(
&
:name
),
{
:include_blank
=>
"Select branch"
})
%tr
%td
=
f
.
label
:assignee_id
,
"Assign to"
%td
=
f
.
select
(
:assignee_id
,
@project
.
users
.
all
.
collect
{
|
p
|
[
p
.
name
,
p
.
id
]
},
{
:include_blank
=>
"Select user"
})
.buttons
=
f
.
submit
'Save'
,
:class
=>
"grey-button"
.right
=
link_to
'Back'
,
project_merge_requests_path
(
@project
),
:class
=>
"grey-button"
:javascript
$
(
function
(){
$
(
'
select#merge_request_assignee_id
'
).
chosen
();
$
(
'
select#merge_request_source_branch
'
).
chosen
();
$
(
'
select#merge_request_target_branch
'
).
chosen
();
});
app/views/merge_requests/_merge_request.html.haml
0 → 100644
View file @
22ac0cc7
%a
.update-item
{
:href
=>
project_merge_request_path
(
@project
,
merge_request
)}
=
image_tag
gravatar_icon
(
merge_request
.
author_email
),
:class
=>
"left"
,
:width
=>
40
%span
.update-title
=
merge_request
.
title
%span
.update-author
%strong
=
merge_request
.
author_name
authored
=
time_ago_in_words
(
merge_request
.
created_at
)
ago
.right
%span
.tag.commit
=
merge_request
.
source_branch
→
%span
.tag.commit
=
merge_request
.
target_branch
app/views/merge_requests/edit.html.haml
0 → 100644
View file @
22ac0cc7
=
render
'form'
app/views/merge_requests/index.html.haml
0 → 100644
View file @
22ac0cc7
-
if
@merge_requests
.
opened
.
count
>
0
%div
{
:class
=>
"update-data ui-box ui-box-small ui-box-big"
}
%h3
%span
.tag.open
Open
.data
=
render
@merge_requests
.
opened
.clear
%br
-
if
@merge_requests
.
closed
.
count
>
0
%div
{
:class
=>
"update-data ui-box ui-box-small ui-box-big"
}
%h3
%span
.tag.closed
Closed
.data
=
render
@merge_requests
.
closed
.clear
%br
=
link_to
'New Merge request'
,
new_project_merge_request_path
(
@project
),
:class
=>
"grey-button"
app/views/merge_requests/new.html.haml
0 → 100644
View file @
22ac0cc7
=
render
'form'
app/views/merge_requests/show.html.haml
0 → 100644
View file @
22ac0cc7
.merge-request-show-holder.ui-box.width-100p
%h3
=
"Merge Request #
#{
@merge_request
.
id
}
:"
.tag.commit.inline
=
@merge_request
.
source_branch
→
.tag.commit.inline
=
@merge_request
.
target_branch
.right
-
if
@merge_request
.
closed
%span
.tag.high
Closed
-
else
%span
.tag.today
Open
.data
%p
=
@merge_request
.
title
-
if
@merge_request
.
author
==
@merge_request
.
assignee
=
image_tag
gravatar_icon
(
@merge_request
.
assignee_email
),
:width
=>
20
,
:style
=>
"padding:0 5px;"
=
@merge_request
.
assignee_name
-
else
=
image_tag
gravatar_icon
(
@merge_request
.
author_email
),
:width
=>
20
,
:style
=>
"padding:0 5px;"
=
@merge_request
.
author_name
→
=
image_tag
gravatar_icon
(
@merge_request
.
assignee_email
),
:width
=>
20
,
:style
=>
"padding:0 5px;"
=
@merge_request
.
assignee_name
.right
%cite
.cgray
=
@merge_request
.
created_at
.
stamp
(
"21 Aug 2011, 11:15pm"
)
.clear
.buttons
-
if
can?
current_user
,
:write_project
,
@project
-
if
@merge_request
.
closed
=
link_to
'Reopen'
,
project_merge_request_path
(
@project
,
@merge_request
,
:merge_request
=>
{
:closed
=>
false
},
:status_only
=>
true
),
:method
=>
:put
,
:class
=>
"grey-button"
-
else
=
link_to
'Close'
,
project_merge_request_path
(
@project
,
@merge_request
,
:merge_request
=>
{
:closed
=>
true
},
:status_only
=>
true
),
:method
=>
:put
,
:class
=>
"grey-button"
.right
=
link_to
'Edit'
,
edit_project_merge_request_path
(
@project
,
@merge_request
),
:class
=>
"grey-button positive"
.clear
%br
%br
#gitlab-tabs
%ul
%li
=
link_to
"Notes"
,
"#merge-notes"
%li
=
link_to
"Commits"
,
commits_project_merge_request_path
(
@project
,
@merge_request
)
%li
=
link_to
"Diff"
,
diffs_project_merge_request_path
(
@project
,
@merge_request
)
#merge-notes
.issue_notes
=
render
"notes/notes"
.loading
{
:style
=>
"display:none;"
}
%center
=
image_tag
"ajax-loader.gif"
.clear
:javascript
$
(
function
(){
$
(
"
#gitlab-tabs
"
).
tabs
();
})
config/routes.rb
View file @
22ac0cc7
...
@@ -59,6 +59,12 @@ Gitlab::Application.routes.draw do
...
@@ -59,6 +59,12 @@ Gitlab::Application.routes.draw do
end
end
end
end
resources
:merge_requests
do
member
do
get
:diffs
get
:commits
end
end
resources
:snippets
resources
:snippets
resources
:commits
resources
:commits
resources
:team_members
resources
:team_members
...
...
db/migrate/20111127155345_create_merge_requests.rb
0 → 100644
View file @
22ac0cc7
class
CreateMergeRequests
<
ActiveRecord
::
Migration
def
change
create_table
:merge_requests
do
|
t
|
t
.
string
:target_branch
,
:null
=>
false
t
.
string
:source_branch
,
:null
=>
false
t
.
integer
:project_id
,
:null
=>
false
t
.
integer
:author_id
t
.
integer
:assignee_id
t
.
string
:title
t
.
boolean
:closed
,
:default
=>
false
,
:null
=>
false
t
.
timestamps
end
end
end
db/schema.rb
View file @
22ac0cc7
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended to check this file into your version control system.
# It's strongly recommended to check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
:version
=>
2011112
4115339
)
do
ActiveRecord
::
Schema
.
define
(
:version
=>
2011112
7155345
)
do
create_table
"features"
,
:force
=>
true
do
|
t
|
create_table
"features"
,
:force
=>
true
do
|
t
|
t
.
string
"name"
t
.
string
"name"
...
@@ -21,6 +21,8 @@ ActiveRecord::Schema.define(:version => 20111124115339) do
...
@@ -21,6 +21,8 @@ ActiveRecord::Schema.define(:version => 20111124115339) do
t
.
integer
"project_id"
t
.
integer
"project_id"
t
.
datetime
"created_at"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
datetime
"updated_at"
t
.
string
"version"
t
.
integer
"status"
,
:default
=>
0
,
:null
=>
false
end
end
create_table
"issues"
,
:force
=>
true
do
|
t
|
create_table
"issues"
,
:force
=>
true
do
|
t
|
...
@@ -45,6 +47,18 @@ ActiveRecord::Schema.define(:version => 20111124115339) do
...
@@ -45,6 +47,18 @@ ActiveRecord::Schema.define(:version => 20111124115339) do
t
.
string
"identifier"
t
.
string
"identifier"
end
end
create_table
"merge_requests"
,
:force
=>
true
do
|
t
|
t
.
string
"target_branch"
,
:null
=>
false
t
.
string
"source_branch"
,
:null
=>
false
t
.
integer
"project_id"
,
:null
=>
false
t
.
integer
"author_id"
t
.
integer
"assignee_id"
t
.
string
"title"
t
.
boolean
"closed"
,
:default
=>
false
,
:null
=>
false
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
end
create_table
"notes"
,
:force
=>
true
do
|
t
|
create_table
"notes"
,
:force
=>
true
do
|
t
|
t
.
text
"note"
t
.
text
"note"
t
.
string
"noteable_id"
t
.
string
"noteable_id"
...
...
spec/factories.rb
View file @
22ac0cc7
...
@@ -34,6 +34,12 @@ Factory.add(:issue, Issue) do |obj|
...
@@ -34,6 +34,12 @@ Factory.add(:issue, Issue) do |obj|
obj
.
title
=
Faker
::
Lorem
.
sentence
obj
.
title
=
Faker
::
Lorem
.
sentence
end
end
Factory
.
add
(
:merge_request
,
MergeRequest
)
do
|
obj
|
obj
.
title
=
Faker
::
Lorem
.
sentence
obj
.
source_branch
=
"master"
obj
.
target_branch
=
"master"
end
Factory
.
add
(
:snippet
,
Snippet
)
do
|
obj
|
Factory
.
add
(
:snippet
,
Snippet
)
do
|
obj
|
obj
.
title
=
Faker
::
Lorem
.
sentence
obj
.
title
=
Faker
::
Lorem
.
sentence
obj
.
file_name
=
Faker
::
Lorem
.
sentence
obj
.
file_name
=
Faker
::
Lorem
.
sentence
...
...
spec/helpers/application_helper_spec.rb
deleted
100644 → 0
View file @
7002b9ff
require
'spec_helper'
describe
ApplicationHelper
do
context
".gravatar_icon"
do
context
"over http"
do
it
"returns the correct URL to www.gravatar.com"
do
expected
=
"http://www.gravatar.com/avatar/f7daa65b2aa96290bb47c4d68d11fe6a?s=40&d=identicon"
# Pretend we're running over HTTP
helper
.
stub
(
:request
)
do
request
=
double
(
'request'
)
request
.
stub
(
:ssl?
)
{
false
}
request
end
helper
.
gravatar_icon
(
"admin@local.host"
).
should
==
expected
end
end
context
"over https"
do
it
"returns the correct URL to secure.gravatar.com"
do
expected
=
"https://secure.gravatar.com/avatar/f7daa65b2aa96290bb47c4d68d11fe6a?s=40&d=identicon"
# Pretend we're running over HTTPS
helper
.
stub
(
:request
)
do
request
=
double
(
'request'
)
request
.
stub
(
:ssl?
)
{
true
}
request
end
helper
.
gravatar_icon
(
"admin@local.host"
).
should
==
expected
end
end
end
end
spec/models/merge_request_spec.rb
0 → 100644
View file @
22ac0cc7
require
'spec_helper'
describe
MergeRequest
do
pending
"add some examples to (or delete)
#{
__FILE__
}
"
end
spec/requests/merge_requests_spec.rb
0 → 100644
View file @
22ac0cc7
require
'spec_helper'
describe
"MergeRequests"
do
let
(
:project
)
{
Factory
:project
}
before
do
login_as
:user
project
.
add_access
(
@user
,
:read
,
:write
)
@merge_request
=
Factory
:merge_request
,
:author
=>
@user
,
:assignee
=>
@user
,
:project
=>
project
end
describe
"GET /merge_requests"
do
before
do
visit
project_merge_requests_path
(
project
)
end
subject
{
page
}
it
{
should
have_content
(
@merge_request
.
title
)
}
it
{
should
have_content
(
@merge_request
.
target_branch
)
}
it
{
should
have_content
(
@merge_request
.
source_branch
)
}
it
{
should
have_content
(
@merge_request
.
assignee
.
name
)
}
end
describe
"GET /merge_request/:id"
do
before
do
visit
project_merge_request_path
(
project
,
@merge_request
)
end
subject
{
page
}
it
{
should
have_content
(
@merge_request
.
title
)
}
it
{
should
have_content
(
@merge_request
.
target_branch
)
}
it
{
should
have_content
(
@merge_request
.
source_branch
)
}
it
{
should
have_content
(
@merge_request
.
assignee
.
name
)
}
describe
"Close merge request"
do
before
{
click_link
"Close"
}
it
{
should
have_content
(
@merge_request
.
title
)
}
it
"Show page should inform user that merge request closed"
do
within
".merge-request-show-holder h3"
do
page
.
should
have_content
"Closed"
end
end
end
end
describe
"GET /merge_requests/new"
do
before
do
visit
new_project_merge_request_path
(
project
)
fill_in
"merge_request_title"
,
:with
=>
"Merge Request Title"
select
"master"
,
:from
=>
"merge_request_source_branch"
select
"master"
,
:from
=>
"merge_request_target_branch"
select
@user
.
name
,
:from
=>
"merge_request_assignee_id"
click_button
"Save"
end
it
{
current_path
.
should
==
project_merge_request_path
(
project
,
project
.
merge_requests
.
last
)
}
it
"should create merge request"
do
page
.
should
have_content
"Open"
page
.
should
have_content
@user
.
name
end
end
end
spec/requests/projects_security_spec.rb
View file @
22ac0cc7
...
@@ -122,5 +122,14 @@ describe "Projects" do
...
@@ -122,5 +122,14 @@ describe "Projects" do
it
{
project_snippets_path
(
@project
).
should
be_denied_for
:user
}
it
{
project_snippets_path
(
@project
).
should
be_denied_for
:user
}
it
{
project_snippets_path
(
@project
).
should
be_denied_for
:visitor
}
it
{
project_snippets_path
(
@project
).
should
be_denied_for
:visitor
}
end
end
describe
"GET /project_code/merge_requests"
do
it
{
project_merge_requests_path
(
@project
).
should
be_allowed_for
@u1
}
it
{
project_merge_requests_path
(
@project
).
should
be_allowed_for
@u3
}
it
{
project_merge_requests_path
(
@project
).
should
be_denied_for
:admin
}
it
{
project_merge_requests_path
(
@project
).
should
be_denied_for
@u2
}
it
{
project_merge_requests_path
(
@project
).
should
be_denied_for
:user
}
it
{
project_merge_requests_path
(
@project
).
should
be_denied_for
:visitor
}
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