Skip to content

Commit

Permalink
Update for missing name and add tests (#320)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Feb 14, 2024
1 parent c754fc7 commit afb39c8
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/stories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def export
@project.stories.includes(:comments).approved.by_position.each do |story|
comments = []
story.comments.each do |comment|
comments << "#{comment.user.name}: #{comment.body}"
comments << "#{display_name(comment.user)}: #{comment.body}"
end
csv << [story.id, story.title, story.description, story.position] + comments
end
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ def markdown(text)

markdown.render(text.to_s).html_safe
end

def display_name(user)
user.name || user.email
end
end
2 changes: 1 addition & 1 deletion app/madmin/resources/user_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class UserResource < Madmin::Resource
attribute :estimates

def self.display_name(record)
record.name.truncate(12)
record.name.truncate(12) || record.email.truncate(12)
end

# Uncomment this to customize the default sort column and direction.
Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ class User < ApplicationRecord

has_many :estimates
has_many :comments

end
2 changes: 1 addition & 1 deletion app/views/comments/_comment.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="comment-card">
<p class="bold"><%= comment.user.name %>: <%= markdown(comment.body) %> <%= comment.created_at %><p>
<p class="bold"><%= display_name(comment.user) %>: <%= markdown(comment.body) %> <%= comment.created_at %><p>
<% if current_user == comment.user %>
<%= link_to "Edit Comment", edit_project_story_comment_path(project, story, comment), class: "link-blue" %> |
<%= link_to "Delete", project_story_comment_path(project, story, comment), method: :delete, data: { confirm: "Are you sure?" }, title: "Delete" %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/reports/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<tr class="project-table__row project-table__row--reports project-table__row--header">
<td class="project-table__cell">Story Title</td>
<% @users.each do |user| %>
<td class="project-table__cell"><%= user.name %>'s Best Estimate</td>
<td class="project-table__cell"><%= user.name %>'s Worst Estimate</td>
<td class="project-table__cell"><%= display_name(user) %>'s Best Estimate</td>
<td class="project-table__cell"><%= display_name(user) %>'s Worst Estimate</td>
<% end %>
<td class="project-table__cell"></td>
<td class="project-table__cell">Average: Best Estimates</td>
Expand Down

0 comments on commit afb39c8

Please sign in to comment.