diff --git a/app/views/issues/_show.html.haml b/app/views/issues/_show.html.haml
index db394873..22101aa1 100644
--- a/app/views/issues/_show.html.haml
+++ b/app/views/issues/_show.html.haml
@@ -35,11 +35,4 @@
- if issue.votes_count > 0
- .votes.votes-inline
- .upvotes= issue.upvotes
- .progress
- - up_percent = 100.0/issue.votes_count*issue.upvotes
- - down_percent = 100.0-up_percent
- .bar.bar-success{style: "width: #{up_percent}%;"}
- .bar.bar-danger{style: "width: #{down_percent}%;"}
- .downvotes= issue.downvotes
+ = render 'votes/votes_inline', votable: issue
diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml
index 1ec03951..9b1c72a3 100644
--- a/app/views/issues/show.html.haml
+++ b/app/views/issues/show.html.haml
@@ -17,14 +17,7 @@
Edit
.right
- .span3.votes.votes-block#votes
- .progress
- - up_percent = 100.0/@issue.votes_count*@issue.upvotes
- - down_percent = 100.0-up_percent
- .bar.bar-success{style: "width: #{up_percent}%;"}
- .bar.bar-danger{style: "width: #{down_percent}%;"}
- .upvotes= "#{@issue.upvotes} up"
- .downvotes= "#{@issue.downvotes} down"
+ .span3#votes= render 'votes/votes_block', votable: @issue
.back_link
= link_to project_issues_path(@project) do
diff --git a/app/views/merge_requests/_merge_request.html.haml b/app/views/merge_requests/_merge_request.html.haml
index 08420fd2..9d94d670 100644
--- a/app/views/merge_requests/_merge_request.html.haml
+++ b/app/views/merge_requests/_merge_request.html.haml
@@ -23,12 +23,6 @@
authored by #{merge_request.author_name}
= time_ago_in_words(merge_request.created_at)
ago
+
- if merge_request.votes_count > 0
- .votes.votes-inline
- .upvotes= merge_request.upvotes
- .progress
- - up_percent = 100.0/merge_request.votes_count*merge_request.upvotes
- - down_percent = 100.0-up_percent
- .bar.bar-success{style: "width: #{up_percent}%;"}
- .bar.bar-danger{style: "width: #{down_percent}%;"}
- .downvotes= merge_request.downvotes
+ = render 'votes/votes_inline', votable: merge_request
diff --git a/app/views/merge_requests/show/_mr_title.html.haml b/app/views/merge_requests/show/_mr_title.html.haml
index c0ad4be5..8708469c 100644
--- a/app/views/merge_requests/show/_mr_title.html.haml
+++ b/app/views/merge_requests/show/_mr_title.html.haml
@@ -24,14 +24,7 @@
Edit
.right
- .span3.votes.votes-block#votes
- .progress
- - up_percent = 100.0/@merge_request.votes_count*@merge_request.upvotes
- - down_percent = 100.0-up_percent
- .bar.bar-success{style: "width: #{up_percent}%;"}
- .bar.bar-danger{style: "width: #{down_percent}%;"}
- .upvotes= "#{@merge_request.upvotes} up"
- .downvotes= "#{@merge_request.downvotes} down"
+ .span3#votes= render 'votes/votes_block', votable: @merge_request
.back_link
= link_to project_merge_requests_path(@project) do
diff --git a/app/views/votes/_votes_block.html.haml b/app/views/votes/_votes_block.html.haml
new file mode 100644
index 00000000..bded53b2
--- /dev/null
+++ b/app/views/votes/_votes_block.html.haml
@@ -0,0 +1,6 @@
+.votes.votes-block
+ .progress
+ .bar.bar-success{style: "width: #{votable.upvotes_in_percent}%;"}
+ .bar.bar-danger{style: "width: #{votable.downvotes_in_percent}%;"}
+ .upvotes= "#{votable.upvotes} up"
+ .downvotes= "#{votable.downvotes} down"
diff --git a/app/views/votes/_votes_inline.html.haml b/app/views/votes/_votes_inline.html.haml
new file mode 100644
index 00000000..91bd200d
--- /dev/null
+++ b/app/views/votes/_votes_inline.html.haml
@@ -0,0 +1,6 @@
+.votes.votes-inline
+ .upvotes= votable.upvotes
+ .progress
+ .bar.bar-success{style: "width: #{votable.upvotes_in_percent}%;"}
+ .bar.bar-danger{style: "width: #{votable.downvotes_in_percent}%;"}
+ .downvotes= votable.downvotes