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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
2d00f2df
Commit
2d00f2df
authored
Mar 15, 2012
by
Ariejan de Vroom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added 'x notes' and +1 counters to issues and merge requests. Refs #549
parent
8d8b8212
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
5 deletions
+52
-5
app/models/merge_request.rb
app/models/merge_request.rb
+6
-1
app/views/issues/_show.html.haml
app/views/issues/_show.html.haml
+2
-0
app/views/issues/show.html.haml
app/views/issues/show.html.haml
+5
-4
app/views/merge_requests/_merge_request.html.haml
app/views/merge_requests/_merge_request.html.haml
+4
-0
app/views/merge_requests/show.html.haml
app/views/merge_requests/show.html.haml
+3
-0
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+32
-0
No files found.
app/models/merge_request.rb
View file @
2d00f2df
...
@@ -34,7 +34,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -34,7 +34,7 @@ class MergeRequest < ActiveRecord::Base
def
validate_branches
def
validate_branches
if
target_branch
==
source_branch
if
target_branch
==
source_branch
errors
.
add
:base
,
"You can not use same branch for source and target branches"
errors
.
add
:base
,
"You can not use same branch for source and target branches"
end
end
end
end
...
@@ -51,6 +51,11 @@ class MergeRequest < ActiveRecord::Base
...
@@ -51,6 +51,11 @@ class MergeRequest < ActiveRecord::Base
def
last_commit
def
last_commit
project
.
commit
(
source_branch
)
project
.
commit
(
source_branch
)
end
end
# Return the number of +1 comments (upvotes)
def
upvotes
notes
.
select
(
&
:upvote?
).
size
end
end
end
# == Schema Information
# == Schema Information
#
#
...
...
app/views/issues/_show.html.haml
View file @
2d00f2df
...
@@ -14,6 +14,8 @@
...
@@ -14,6 +14,8 @@
%span
.label.important
critical
%span
.label.important
critical
-
if
issue
.
today?
-
if
issue
.
today?
%span
.label.success
today
%span
.label.success
today
-
if
issue
.
notes
.
any?
%span
.label
=
pluralize
issue
.
notes
.
count
,
'note'
-
if
issue
.
upvotes
>
0
-
if
issue
.
upvotes
>
0
%span
.label.success
=
"+
#{
issue
.
upvotes
}
"
%span
.label.success
=
"+
#{
issue
.
upvotes
}
"
...
...
app/views/issues/show.html.haml
View file @
2d00f2df
...
@@ -11,9 +11,13 @@
...
@@ -11,9 +11,13 @@
-
else
-
else
=
link_to
'Close'
,
project_issue_path
(
@project
,
@issue
,
:issue
=>
{
:closed
=>
true
},
:status_only
=>
true
),
:method
=>
:put
,
:class
=>
"btn"
,
:title
=>
"Close Issue"
=
link_to
'Close'
,
project_issue_path
(
@project
,
@issue
,
:issue
=>
{
:closed
=>
true
},
:status_only
=>
true
),
:method
=>
:put
,
:class
=>
"btn"
,
:title
=>
"Close Issue"
-
if
can?
(
current_user
,
:admin_project
,
@project
)
||
@issue
.
author
==
current_user
-
if
can?
(
current_user
,
:admin_project
,
@project
)
||
@issue
.
author
==
current_user
=
link_to
edit_project_issue_path
(
@project
,
@issue
),
:class
=>
"btn
small
"
do
=
link_to
edit_project_issue_path
(
@project
,
@issue
),
:class
=>
"btn"
do
Edit
Edit
-
if
@issue
.
upvotes
>
0
%button
.btn.success
=
"+
#{
@issue
.
upvotes
}
"
.back_link
.back_link
=
link_to
project_issues_path
(
@project
)
do
=
link_to
project_issues_path
(
@project
)
do
←
To issues list
←
To issues list
...
@@ -36,9 +40,6 @@
...
@@ -36,9 +40,6 @@
=
image_tag
gravatar_icon
(
@issue
.
assignee_email
),
:width
=>
16
,
:class
=>
"lil_av"
=
image_tag
gravatar_icon
(
@issue
.
assignee_email
),
:width
=>
16
,
:class
=>
"lil_av"
%strong
.author
=
link_to_issue_assignee
(
@issue
)
%strong
.author
=
link_to_issue_assignee
(
@issue
)
-
if
@issue
.
upvotes
>
0
%span
.label.success
=
"+
#{
@issue
.
upvotes
}
"
%hr
%hr
%div
=
simple_format
@issue
.
title
%div
=
simple_format
@issue
.
title
...
...
app/views/merge_requests/_merge_request.html.haml
View file @
2d00f2df
...
@@ -5,6 +5,10 @@
...
@@ -5,6 +5,10 @@
authored
authored
=
time_ago_in_words
(
merge_request
.
created_at
)
=
time_ago_in_words
(
merge_request
.
created_at
)
ago
ago
-
if
merge_request
.
notes
.
any?
%span
.label
=
pluralize
merge_request
.
notes
.
count
,
'note'
-
if
merge_request
.
upvotes
>
0
%span
.label.success
=
"+
#{
merge_request
.
upvotes
}
"
.right
.right
%span
.label
=
merge_request
.
source_branch
%span
.label
=
merge_request
.
source_branch
→
→
...
...
app/views/merge_requests/show.html.haml
View file @
2d00f2df
...
@@ -18,6 +18,9 @@
...
@@ -18,6 +18,9 @@
=
link_to
edit_project_merge_request_path
(
@project
,
@merge_request
),
:class
=>
"btn small"
do
=
link_to
edit_project_merge_request_path
(
@project
,
@merge_request
),
:class
=>
"btn small"
do
Edit
Edit
-
if
@merge_request
.
upvotes
>
0
%button
.btn.success
=
"+
#{
@merge_request
.
upvotes
}
"
.back_link
.back_link
=
link_to
project_merge_requests_path
(
@project
)
do
=
link_to
project_merge_requests_path
(
@project
)
do
←
To merge requests
←
To merge requests
...
...
spec/models/merge_request_spec.rb
View file @
2d00f2df
...
@@ -25,6 +25,38 @@ describe MergeRequest do
...
@@ -25,6 +25,38 @@ describe MergeRequest do
:author
=>
Factory
(
:user
),
:author
=>
Factory
(
:user
),
:assignee
=>
Factory
(
:user
),
:assignee
=>
Factory
(
:user
),
:project
=>
Factory
.
create
(
:project
)).
should
be_valid
}
:project
=>
Factory
.
create
(
:project
)).
should
be_valid
}
describe
"plus 1"
do
let
(
:project
)
{
Factory
(
:project
)
}
subject
{
Factory
.
create
(
:merge_request
,
:author
=>
Factory
(
:user
),
:assignee
=>
Factory
(
:user
),
:project
=>
project
)
}
it
"with no notes has a 0/0 score"
do
subject
.
upvotes
.
should
==
0
end
it
"should recognize non-+1 notes"
do
subject
.
notes
<<
Factory
(
:note
,
note:
"No +1 here"
,
project:
Factory
(
:project
,
path:
'plusone'
,
code:
'plusone'
))
subject
.
should
have
(
1
).
note
subject
.
notes
.
first
.
upvote?
.
should
be_false
subject
.
upvotes
.
should
==
0
end
it
"should recognize a single +1 note"
do
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 This is awesome"
,
project:
Factory
(
:project
,
path:
'plusone'
,
code:
'plusone'
))
subject
.
upvotes
.
should
==
1
end
it
"should recognize a multiple +1 notes"
do
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 This is awesome"
,
project:
Factory
(
:project
,
path:
'plusone'
,
code:
'plusone'
))
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 I want this"
,
project:
Factory
(
:project
,
path:
'plustwo'
,
code:
'plustwo'
))
subject
.
upvotes
.
should
==
2
end
end
end
end
# == Schema Information
# == Schema Information
#
#
...
...
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