From e44af4f0dc605e5895b840b785787a2f14bbce7f Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 22:16:55 +0000 Subject: [PATCH] Show how long ago each download permission was first granted The datatable's permissions page gets a "First granted" column ("3 months ago", with the date on hover), from permissions.created_at. Extending a permission keeps the same row, so this is when access was first given; older rows without a creation date show nothing. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016AR3uoZS1uCC8hXmojk3K7 --- app/views/permissions/show.html.erb | 8 ++++++++ spec/requests/permissions_spec.rb | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/views/permissions/show.html.erb b/app/views/permissions/show.html.erb index af159ed7..0c77a19c 100644 --- a/app/views/permissions/show.html.erb +++ b/app/views/permissions/show.html.erb @@ -26,6 +26,7 @@ Account Intended use Granted by + First granted Access until @@ -38,6 +39,13 @@ <%= permission.intended_use %> <%= permission.granted_by&.email %> + + <% if permission.created_at %> + + <% end %> + <% if permission.expires_on.nil? %> No expiry diff --git a/spec/requests/permissions_spec.rb b/spec/requests/permissions_spec.rb index f3301852..1f773df3 100644 --- a/spec/requests/permissions_spec.rb +++ b/spec/requests/permissions_spec.rb @@ -111,11 +111,13 @@ def grant(email, expires_in: nil) it 'shows requests and grants on the datatable page' do PermissionRequest.create!(user: FactoryBot.create(:user, email: 'asker@example.org'), datatable:) - Permission.create!(datatable:, user: reader, granted_by: admin, expires_on: Date.new(2030, 5, 1)) + Permission.create!(datatable:, user: reader, granted_by: admin, expires_on: Date.new(2030, 5, 1), + created_at: 3.months.ago) get permission_path(datatable) - expect(response.body).to include('asker@example.org has asked', 'reader@example.org', 'May 01, 2030') + expect(response.body).to include('asker@example.org has asked', 'reader@example.org', 'May 01, 2030', + '3 months ago') end end