Skip to content

Commit afb39c8

Browse files
FionaDLaisayoetagwerker
authored
Update for missing name and add tests (#320)
* Update for missing name and add tests * Update according to feedback * Update call to display_name * Remove spec that doesn't test anything anymore --------- Co-authored-by: aisayo <[email protected]> Co-authored-by: Ernesto Tagwerker <[email protected]>
1 parent c754fc7 commit afb39c8

File tree

6 files changed

+10
-5
lines changed

6 files changed

+10
-5
lines changed

app/controllers/stories_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def export
9393
@project.stories.includes(:comments).approved.by_position.each do |story|
9494
comments = []
9595
story.comments.each do |comment|
96-
comments << "#{comment.user.name}: #{comment.body}"
96+
comments << "#{display_name(comment.user)}: #{comment.body}"
9797
end
9898
csv << [story.id, story.title, story.description, story.position] + comments
9999
end

app/helpers/application_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ def markdown(text)
3333

3434
markdown.render(text.to_s).html_safe
3535
end
36+
37+
def display_name(user)
38+
user.name || user.email
39+
end
3640
end

app/madmin/resources/user_resource.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class UserResource < Madmin::Resource
99
attribute :estimates
1010

1111
def self.display_name(record)
12-
record.name.truncate(12)
12+
record.name.truncate(12) || record.email.truncate(12)
1313
end
1414

1515
# Uncomment this to customize the default sort column and direction.

app/models/user.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ class User < ApplicationRecord
33

44
has_many :estimates
55
has_many :comments
6+
67
end

app/views/comments/_comment.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="comment-card">
2-
<p class="bold"><%= comment.user.name %>: <%= markdown(comment.body) %> <%= comment.created_at %><p>
2+
<p class="bold"><%= display_name(comment.user) %>: <%= markdown(comment.body) %> <%= comment.created_at %><p>
33
<% if current_user == comment.user %>
44
<%= link_to "Edit Comment", edit_project_story_comment_path(project, story, comment), class: "link-blue" %> |
55
<%= link_to "Delete", project_story_comment_path(project, story, comment), method: :delete, data: { confirm: "Are you sure?" }, title: "Delete" %>

app/views/reports/show.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<tr class="project-table__row project-table__row--reports project-table__row--header">
99
<td class="project-table__cell">Story Title</td>
1010
<% @users.each do |user| %>
11-
<td class="project-table__cell"><%= user.name %>'s Best Estimate</td>
12-
<td class="project-table__cell"><%= user.name %>'s Worst Estimate</td>
11+
<td class="project-table__cell"><%= display_name(user) %>'s Best Estimate</td>
12+
<td class="project-table__cell"><%= display_name(user) %>'s Worst Estimate</td>
1313
<% end %>
1414
<td class="project-table__cell"></td>
1515
<td class="project-table__cell">Average: Best Estimates</td>

0 commit comments

Comments
 (0)