Add an OFN UID column to the Users & Enterprises report

This commit is contained in:
Cillian O'Ruanaidh
2023-06-16 15:03:40 +01:00
committed by Konrad
parent e065910d2d
commit 40b0bfb433
3 changed files with 58 additions and 2 deletions

View File

@@ -2870,6 +2870,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
report_filters: Report Filters
report_print: Print Report
report_render_options: Rendering Options
report_header_ofn_uid: OFN UID
report_header_order_cycle: Order Cycle
report_header_user: User
report_header_email: Email

View File

@@ -16,7 +16,8 @@ module Reporting
is_producer: proc { |x| x.is_primary_producer },
sells: proc { |x| x.sells },
visible: proc { |x| x.visible },
confirmation_date: proc { |x| x.created_at }
confirmation_date: proc { |x| x.created_at },
ofn_uid: proc { |x| x.ofn_uid }
}
end
@@ -46,7 +47,8 @@ module Reporting
def query_helper(query, email_user, relationship_type)
query.order("enterprises.created_at DESC")
.select(["enterprises.name",
.select(["enterprises.id AS ofn_uid",
"enterprises.name",
"enterprises.sells",
"enterprises.visible",
"enterprises.is_primary_producer",

View File

@@ -0,0 +1,53 @@
# frozen_string_literal: true
require 'system_helper'
describe "Users & Enterprises reports" do
include AuthenticationHelper
let!(:enterprise) { create(:supplier_enterprise) }
before do
login_as_admin
visit main_app.admin_report_path(report_type: 'users_and_enterprises')
end
it "displays the report" do
find("[type='submit']").click
expect(page.find("table.report__table thead tr").text).to have_content([
"USER",
"RELATIONSHIP",
"ENTERPRISE",
"PRODUCER?",
"SELLS",
"VISIBLE",
"CONFIRMATION DATE",
"OFN UID"
].join(" "))
row_i, row_ii = page.all("table.report__table tbody tr").map(&:text)
expect(row_i).to have_content([
enterprise.owner.email,
"owns",
enterprise.name,
"Yes",
"none",
"public",
enterprise.created_at.strftime("%Y-%m-%d %H:%M"),
enterprise.id
].compact.join(" "))
expect(row_ii).to have_content([
enterprise.owner.email,
"manages",
enterprise.name,
"Yes",
"none",
"public",
enterprise.created_at.strftime("%Y-%m-%d %H:%M"),
enterprise.id
].compact.join(" "))
end
end