Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for missing name and add tests #320

Merged
merged 4 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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).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
Loading