From 3abd977822247581465ff6d6df52d2c08e8da508 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Thu, 3 Nov 2011 06:56:26 -0400 Subject: [PATCH] fixed error with ascii error for dashboard --- app/models/issue.rb | 5 +++++ app/models/note.rb | 5 +++++ app/views/commits/_commits.html.haml | 6 +++--- app/views/commits/show.html.haml | 2 +- app/views/dashboard/index.html.haml | 4 ++-- lib/commit_ext.rb | 8 ++++++++ 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index 9fb7ef3060a..f649cacbacf 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -10,6 +10,11 @@ class Issue < ActiveRecord::Base validates_presence_of :assignee_id validates_presence_of :author_id + delegate :name, + :email, + :to => :author, + :prefix => true + validates :title, :presence => true, :length => { :within => 0..255 } diff --git a/app/models/note.rb b/app/models/note.rb index 645bc7cec12..3c59efefb1b 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -7,6 +7,11 @@ class Note < ActiveRecord::Base belongs_to :author, :class_name => "User" + delegate :name, + :email, + :to => :author, + :prefix => true + attr_protected :author, :author_id validates_presence_of :project diff --git a/app/views/commits/_commits.html.haml b/app/views/commits/_commits.html.haml index 36225d37ebd..9761c65fa1c 100644 --- a/app/views/commits/_commits.html.haml +++ b/app/views/commits/_commits.html.haml @@ -11,15 +11,15 @@ %i %data.commit-browse{ :onclick => "location.href='#{tree_project_path(@project, :commit_id => commit.id)}';return false;"} Browse Code - - if commit.author.email - = image_tag gravatar_icon(commit.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" + - 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.commit-title %strong = truncate(commit.safe_message, :length => 60) %span.commit-author - %strong= commit.author + %strong= commit.author_name = time_ago_in_words(commit.committed_date) ago = more_commits_link if @commits.size > 99 diff --git a/app/views/commits/show.html.haml b/app/views/commits/show.html.haml index 3227a447a60..3bd9145e1d7 100644 --- a/app/views/commits/show.html.haml +++ b/app/views/commits/show.html.haml @@ -7,7 +7,7 @@ %td= @commit.id %tr %td Author - %td= @commit.author + %td= @commit.author_name %tr %td Commiter %td= @commit.committer diff --git a/app/views/dashboard/index.html.haml b/app/views/dashboard/index.html.haml index 761826cae52..eb2122dff8f 100644 --- a/app/views/dashboard/index.html.haml +++ b/app/views/dashboard/index.html.haml @@ -25,11 +25,11 @@ .data - project.updates.each do |update| %a.project-update{:href => dashboard_feed_path(project, update)} - = image_tag gravatar_icon(update.author.email), :class => "left", :width => 40 + = image_tag gravatar_icon(update.author_email), :class => "left", :width => 40 %span.update-title = dashboard_feed_title(update) %span.update-author - %strong= update.author.name + %strong= update.author_name authored = time_ago_in_words(update.created_at) ago diff --git a/lib/commit_ext.rb b/lib/commit_ext.rb index 32706acb617..db6503557ae 100644 --- a/lib/commit_ext.rb +++ b/lib/commit_ext.rb @@ -12,4 +12,12 @@ module CommitExt def created_at committed_date end + + def author_email + author.email.force_encoding(Encoding::UTF_8) + end + + def author_name + author.name.force_encoding(Encoding::UTF_8) + end end