Skip to content

Commit

Permalink
Handle nil value for fixity_last_success_date in fixity dashboard
Browse files Browse the repository at this point in the history
fixes #897
  • Loading branch information
hackartisan committed Mar 13, 2018
1 parent 28e2540 commit 85234f2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/helpers/fixity_dashboard_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true
module FixityDashboardHelper
def format_fixity_success_date(date)
date.nil? ? 'in progress' : date.strftime("%m/%d/%y %I:%M:%S %p %Z")
end
end
2 changes: 1 addition & 1 deletion app/views/fixity_dashboard/_fixity_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<td><%= link_to resource.parent.title.first, Valhalla::ContextualPath.new(child: resource.parent).show %></td>
<td><%= resource.original_file.fixity_success == 0 ? "failed" : "succeeded" %></td>
<td><%= resource.updated_at %></td>
<td><%= resource.original_file.fixity_last_success_date.strftime("%m/%d/%y %I:%M:%S %p %Z") %></td>
<td><%= format_fixity_success_date(resource.original_file.fixity_last_success_date) %></td>
</tr>
<% end %>
</tbody>
Expand Down
12 changes: 12 additions & 0 deletions spec/helpers/fixity_dashboard_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true
require 'rails_helper'

RSpec.describe FixityDashboardHelper do
describe '#format_fixity_success_date' do
it 'formats the date as expected' do
expect(helper.format_fixity_success_date(nil)).to eq 'in progress'
time = Time.current
expect(helper.format_fixity_success_date(time)).to eq time.strftime("%m/%d/%y %I:%M:%S %p %Z")
end
end
end

0 comments on commit 85234f2

Please sign in to comment.