Commit afe98ae74ab13d11908e74ada1d10dccc333228b
1 parent
5baa5fad
Exists in
master
and in
4 other branches
Issue #149 fixed
Showing
7 changed files
with
15 additions
and
11 deletions
Show diff stats
app/views/commits/_commits.html.haml
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" | 11 | = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" |
12 | %p | 12 | %p |
13 | %strong | 13 | %strong |
14 | - = commit.truncated_message | 14 | + = truncate(commit.safe_message, :length => 60) |
15 | = link_to "Browse Code", tree_project_path(@project, :commit_id => commit.id), :class => "lite_button", :style => "float:right" | 15 | = link_to "Browse Code", tree_project_path(@project, :commit_id => commit.id), :class => "lite_button", :style => "float:right" |
16 | = link_to truncate(commit.id.to_s, :length => 16), project_commit_path(@project, :id => commit.id), :class => "lite_button", :style => "width:120px;float:right" | 16 | = link_to truncate(commit.id.to_s, :length => 16), project_commit_path(@project, :id => commit.id), :class => "lite_button", :style => "width:120px;float:right" |
17 | %span | 17 | %span |
app/views/commits/show.html.haml
1 | %h3 | 1 | %h3 |
2 | - = "[ #{@commit.committer} ] #{@commit.truncated_message(40)}" | 2 | + = "[ #{@commit.committer} ] #{truncate(@commit.safe_message)}" |
3 | -#= link_to 'Back', project_commits_path(@project), :class => "button" | 3 | -#= link_to 'Back', project_commits_path(@project), :class => "button" |
4 | %table.round-borders | 4 | %table.round-borders |
5 | %tr | 5 | %tr |
@@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
16 | %td= @commit.committed_date | 16 | %td= @commit.committed_date |
17 | %tr | 17 | %tr |
18 | %td Message | 18 | %td Message |
19 | - %td= @commit.message | 19 | + %td= @commit.safe_message |
20 | %tr | 20 | %tr |
21 | %td Tree | 21 | %td Tree |
22 | %td= link_to 'Browse Code', tree_project_path(@project, :commit_id => @commit.id) | 22 | %td= link_to 'Browse Code', tree_project_path(@project, :commit_id => @commit.id) |
app/views/projects/_recent_commits.html.haml
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" | 6 | = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" |
7 | %p{:style => "margin-bottom: 3px;"} | 7 | %p{:style => "margin-bottom: 3px;"} |
8 | %strong | 8 | %strong |
9 | - = link_to commit.truncated_message(60), project_commit_path(@project, :id => commit.id) | 9 | + = link_to truncate(commit.safe_message, :length => 60), project_commit_path(@project, :id => commit.id) |
10 | 10 | ||
11 | %span | 11 | %span |
12 | %span.author | 12 | %span.author |
app/views/projects/_recent_messages.html.haml
@@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
19 | - css_class = "dash_commit" | 19 | - css_class = "dash_commit" |
20 | - commit = parent | 20 | - commit = parent |
21 | - item_code = commit.author.email | 21 | - item_code = commit.author.email |
22 | - - link_item_name = commit.truncated_message(50) | 22 | + - link_item_name = truncate(commit.safe_message, :length => 50) |
23 | - link_to_item = project_commit_path(@project, :id => commit.id) | 23 | - link_to_item = project_commit_path(@project, :id => commit.id) |
24 | - else | 24 | - else |
25 | - css_class = "dash_wall" | 25 | - css_class = "dash_wall" |
app/views/projects/_tree_item.html.haml
@@ -12,4 +12,4 @@ | @@ -12,4 +12,4 @@ | ||
12 | = time_ago_in_words(content_commit.committed_date) | 12 | = time_ago_in_words(content_commit.committed_date) |
13 | ago | 13 | ago |
14 | %td | 14 | %td |
15 | - = link_to content_commit.truncated_message(40), project_commit_path(@project, content_commit) | 15 | + = link_to truncate(content_commit.safe_message, :length => 40), project_commit_path(@project, content_commit) |
lib/commit_ext.rb
1 | module CommitExt | 1 | module CommitExt |
2 | - # Cause of encoding rails truncate raise error | ||
3 | - # this method is temporary decision | ||
4 | - def truncated_message(size = 80) | ||
5 | - message.length > size ? (message[0..(size - 1)] + "...") : message | 2 | + def safe_message |
3 | + message.encode("UTF-8", | ||
4 | + :invalid => :replace, | ||
5 | + :undef => :replace, | ||
6 | + :universal_newline => true, | ||
7 | + :replace => "") | ||
6 | rescue | 8 | rescue |
7 | "-- invalid encoding for commit message" | 9 | "-- invalid encoding for commit message" |
8 | end | 10 | end |
spec/requests/team_members_spec.rb
@@ -10,7 +10,9 @@ describe "TeamMembers" do | @@ -10,7 +10,9 @@ describe "TeamMembers" do | ||
10 | describe "View profile" do | 10 | describe "View profile" do |
11 | it "should be available" do | 11 | it "should be available" do |
12 | visit(team_project_path(@project)) | 12 | visit(team_project_path(@project)) |
13 | - find(:xpath, "//table[@id='team-table']//a[1]").click | 13 | + within "#team-table" do |
14 | + click_link(@user.name) | ||
15 | + end | ||
14 | page.should have_content @user.skype | 16 | page.should have_content @user.skype |
15 | page.should_not have_content 'Twitter' | 17 | page.should_not have_content 'Twitter' |
16 | end | 18 | end |