From 2564ea13be86a2b303c9f23b8b64f1b646da85da Mon Sep 17 00:00:00 2001 From: Anna Headley Date: Tue, 13 Mar 2018 11:25:37 -0400 Subject: [PATCH] Add formatting for fixity success valule, fixes #901 --- app/helpers/fixity_dashboard_helper.rb | 11 +++++++++++ app/views/fixity_dashboard/_fixity_table.html.erb | 2 +- spec/helpers/fixity_dashboard_helper_spec.rb | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/helpers/fixity_dashboard_helper.rb b/app/helpers/fixity_dashboard_helper.rb index 32190b4914..c4f3bd2453 100644 --- a/app/helpers/fixity_dashboard_helper.rb +++ b/app/helpers/fixity_dashboard_helper.rb @@ -3,4 +3,15 @@ module FixityDashboardHelper def format_fixity_success_date(date) date.nil? ? 'in progress' : date.strftime("%m/%d/%y %I:%M:%S %p %Z") end + + def format_fixity_success(val) + case val + when nil + "in progress" + when 0 + "failed" + when 1 + "succeeded" + end + end end diff --git a/app/views/fixity_dashboard/_fixity_table.html.erb b/app/views/fixity_dashboard/_fixity_table.html.erb index 0372a4c333..b3e965ba7a 100644 --- a/app/views/fixity_dashboard/_fixity_table.html.erb +++ b/app/views/fixity_dashboard/_fixity_table.html.erb @@ -13,7 +13,7 @@ <%= link_to resource.title.first, Valhalla::ContextualPath.new(child: resource, parent_id: resource.parent.id).show %> <%= link_to resource.parent.title.first, Valhalla::ContextualPath.new(child: resource.parent).show %> - <%= resource.original_file.fixity_success == 0 ? "failed" : "succeeded" %> + <%= format_fixity_success(resource.original_file.fixity_success) %> <%= resource.updated_at %> <%= format_fixity_success_date(resource.original_file.fixity_last_success_date) %> diff --git a/spec/helpers/fixity_dashboard_helper_spec.rb b/spec/helpers/fixity_dashboard_helper_spec.rb index 474e778406..6f72e50ec3 100644 --- a/spec/helpers/fixity_dashboard_helper_spec.rb +++ b/spec/helpers/fixity_dashboard_helper_spec.rb @@ -9,4 +9,12 @@ expect(helper.format_fixity_success_date(time)).to eq time.strftime("%m/%d/%y %I:%M:%S %p %Z") end end + + describe '#format_fixity_success' do + it 'translates the nil / 0 / 1 into human-readable text' do + expect(helper.format_fixity_success(nil)).to eq 'in progress' + expect(helper.format_fixity_success(0)).to eq 'failed' + expect(helper.format_fixity_success(1)).to eq 'succeeded' + end + end end