summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgitlabhq <m@gitlabhq.com>2011-10-25 07:32:02 +0300
committergitlabhq <m@gitlabhq.com>2011-10-25 07:32:02 +0300
commitafe98ae74ab13d11908e74ada1d10dccc333228b (patch)
tree59b347ca22fa523d5bdc2d8603a15502e397b90b
parent5baa5fad0a1c6e2b8790f07f62c088fd505406d9 (diff)
downloadgitlab-ce-afe98ae74ab13d11908e74ada1d10dccc333228b.tar.gz
Issue #149 fixed
-rw-r--r--app/views/commits/_commits.html.haml2
-rw-r--r--app/views/commits/show.html.haml4
-rw-r--r--app/views/projects/_recent_commits.html.haml2
-rw-r--r--app/views/projects/_recent_messages.html.haml2
-rw-r--r--app/views/projects/_tree_item.html.haml2
-rw-r--r--lib/commit_ext.rb10
-rw-r--r--spec/requests/team_members_spec.rb4
7 files changed, 15 insertions, 11 deletions
diff --git a/app/views/commits/_commits.html.haml b/app/views/commits/_commits.html.haml
index 3ed70f1cffb..9982306547e 100644
--- a/app/views/commits/_commits.html.haml
+++ b/app/views/commits/_commits.html.haml
@@ -11,7 +11,7 @@
= image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;"
%p
%strong
- = commit.truncated_message
+ = truncate(commit.safe_message, :length => 60)
= link_to "Browse Code", tree_project_path(@project, :commit_id => commit.id), :class => "lite_button", :style => "float:right"
= link_to truncate(commit.id.to_s, :length => 16), project_commit_path(@project, :id => commit.id), :class => "lite_button", :style => "width:120px;float:right"
%span
diff --git a/app/views/commits/show.html.haml b/app/views/commits/show.html.haml
index 0ba42618470..3beeada8c8c 100644
--- a/app/views/commits/show.html.haml
+++ b/app/views/commits/show.html.haml
@@ -1,5 +1,5 @@
%h3
- = "[ #{@commit.committer} ] #{@commit.truncated_message(40)}"
+ = "[ #{@commit.committer} ] #{truncate(@commit.safe_message)}"
-#= link_to 'Back', project_commits_path(@project), :class => "button"
%table.round-borders
%tr
@@ -16,7 +16,7 @@
%td= @commit.committed_date
%tr
%td Message
- %td= @commit.message
+ %td= @commit.safe_message
%tr
%td Tree
%td= link_to 'Browse Code', tree_project_path(@project, :commit_id => @commit.id)
diff --git a/app/views/projects/_recent_commits.html.haml b/app/views/projects/_recent_commits.html.haml
index 36f4b636d22..3157c356862 100644
--- a/app/views/projects/_recent_commits.html.haml
+++ b/app/views/projects/_recent_commits.html.haml
@@ -6,7 +6,7 @@
= image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;"
%p{:style => "margin-bottom: 3px;"}
%strong
- = link_to commit.truncated_message(60), project_commit_path(@project, :id => commit.id)
+ = link_to truncate(commit.safe_message, :length => 60), project_commit_path(@project, :id => commit.id)
%span
%span.author
diff --git a/app/views/projects/_recent_messages.html.haml b/app/views/projects/_recent_messages.html.haml
index 36f1435b15c..67f3449bd9b 100644
--- a/app/views/projects/_recent_messages.html.haml
+++ b/app/views/projects/_recent_messages.html.haml
@@ -19,7 +19,7 @@
- css_class = "dash_commit"
- commit = parent
- item_code = commit.author.email
- - link_item_name = commit.truncated_message(50)
+ - link_item_name = truncate(commit.safe_message, :length => 50)
- link_to_item = project_commit_path(@project, :id => commit.id)
- else
- css_class = "dash_wall"
diff --git a/app/views/projects/_tree_item.html.haml b/app/views/projects/_tree_item.html.haml
index 538d2cc6e68..53c05d5a429 100644
--- a/app/views/projects/_tree_item.html.haml
+++ b/app/views/projects/_tree_item.html.haml
@@ -12,4 +12,4 @@
= time_ago_in_words(content_commit.committed_date)
ago
%td
- = link_to content_commit.truncated_message(40), project_commit_path(@project, content_commit)
+ = link_to truncate(content_commit.safe_message, :length => 40), project_commit_path(@project, content_commit)
diff --git a/lib/commit_ext.rb b/lib/commit_ext.rb
index c175fa0cc2d..e09dbdaf8ef 100644
--- a/lib/commit_ext.rb
+++ b/lib/commit_ext.rb
@@ -1,8 +1,10 @@
module CommitExt
- # Cause of encoding rails truncate raise error
- # this method is temporary decision
- def truncated_message(size = 80)
- message.length > size ? (message[0..(size - 1)] + "...") : message
+ def safe_message
+ message.encode("UTF-8",
+ :invalid => :replace,
+ :undef => :replace,
+ :universal_newline => true,
+ :replace => "")
rescue
"-- invalid encoding for commit message"
end
diff --git a/spec/requests/team_members_spec.rb b/spec/requests/team_members_spec.rb
index ec0af3214a9..650ed4497f2 100644
--- a/spec/requests/team_members_spec.rb
+++ b/spec/requests/team_members_spec.rb
@@ -10,7 +10,9 @@ describe "TeamMembers" do
describe "View profile" do
it "should be available" do
visit(team_project_path(@project))
- find(:xpath, "//table[@id='team-table']//a[1]").click
+ within "#team-table" do
+ click_link(@user.name)
+ end
page.should have_content @user.skype
page.should_not have_content 'Twitter'
end