diff --git a/app/helpers/fixity_dashboard_helper.rb b/app/helpers/fixity_dashboard_helper.rb new file mode 100644 index 0000000000..32190b4914 --- /dev/null +++ b/app/helpers/fixity_dashboard_helper.rb @@ -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 diff --git a/app/views/fixity_dashboard/_fixity_table.html.erb b/app/views/fixity_dashboard/_fixity_table.html.erb index f995d0dc17..0372a4c333 100644 --- a/app/views/fixity_dashboard/_fixity_table.html.erb +++ b/app/views/fixity_dashboard/_fixity_table.html.erb @@ -15,7 +15,7 @@ <%= link_to resource.parent.title.first, Valhalla::ContextualPath.new(child: resource.parent).show %> <%= resource.original_file.fixity_success == 0 ? "failed" : "succeeded" %> <%= resource.updated_at %> - <%= resource.original_file.fixity_last_success_date.strftime("%m/%d/%y %I:%M:%S %p %Z") %> + <%= format_fixity_success_date(resource.original_file.fixity_last_success_date) %> <% end %> diff --git a/spec/helpers/fixity_dashboard_helper_spec.rb b/spec/helpers/fixity_dashboard_helper_spec.rb new file mode 100644 index 0000000000..474e778406 --- /dev/null +++ b/spec/helpers/fixity_dashboard_helper_spec.rb @@ -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