Skip to content

Commit

Permalink
Merge pull request #902 from pulibrary/fixity-success-display
Browse files Browse the repository at this point in the history
Add formatting for fixity success valule
  • Loading branch information
escowles committed Mar 13, 2018
2 parents 0ac87e9 + 2564ea1 commit 45f2afc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/helpers/fixity_dashboard_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -13,7 +13,7 @@
<tr>
<td><%= link_to resource.title.first, Valhalla::ContextualPath.new(child: resource, parent_id: resource.parent.id).show %></td>
<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><%= format_fixity_success(resource.original_file.fixity_success) %></td>
<td><%= resource.updated_at %></td>
<td><%= format_fixity_success_date(resource.original_file.fixity_last_success_date) %></td>
</tr>
Expand Down
8 changes: 8 additions & 0 deletions spec/helpers/fixity_dashboard_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 45f2afc

Please sign in to comment.