diff --git a/app/models/reports/nomination.rb b/app/models/reports/nomination.rb index 0ccb64e5a..e3280f8f8 100644 --- a/app/models/reports/nomination.rb +++ b/app/models/reports/nomination.rb @@ -85,6 +85,26 @@ def secondary_activity obj.secondary_activity.presence && NomineeActivityHelper.lookup_label_for_activity(obj.secondary_activity.to_sym) end + def nominee_established_date + doc["nominee_established_date"] + end + + def group_activities + doc["group_activities"] + end + + def beneficiaries + doc["beneficiaries"] + end + + def benefits + doc["benefits"] + end + + def volunteers + doc["volunteers"] + end + def ceremonial_county obj.ceremonial_county.try(:name) end diff --git a/app/models/reports/nominations_report.rb b/app/models/reports/nominations_report.rb index 9daa092fa..3dd4368bd 100644 --- a/app/models/reports/nominations_report.rb +++ b/app/models/reports/nominations_report.rb @@ -64,7 +64,27 @@ class Reports::NominationsReport < Reports::QavsBase { label: "Assigned Sub-Group", method: :sub_group, - } + }, + { + label: "Year founded", + method: :nominee_established_date, + }, + { + label: "Please summarise the activities of the group", + method: :group_activities, + }, + { + label: "Who are the beneficiaries (the people it helps) and where do they live?", + method: :beneficiaries, + }, + { + label: "What are the benefits of the group's work?", + method: :benefits, + }, + { + label: "This Award is specifically for groups that rely on significant and committed work by volunteers. Please explain what the volunteers do and what makes this particular group of volunteers so impressive?", + method: :volunteers, + }, ] private diff --git a/spec/models/reports/nominations_report_spec.rb b/spec/models/reports/nominations_report_spec.rb new file mode 100644 index 000000000..560eaa3e6 --- /dev/null +++ b/spec/models/reports/nominations_report_spec.rb @@ -0,0 +1,31 @@ +require 'rails_helper' +require 'csv' + +RSpec.describe Reports::NominationsReport, type: :model do + let!(:form_answer) { create(:form_answer) } + let(:report) { Reports::NominationsReport.new(FormAnswer.all).build } + let(:csv_content) { CSV.parse(report, headers: true) } + + context 'renders the report with data' do + it "renders rows" do + expect(csv_content.length).to eq(1) + end + + it "renders the correct columns" do + columns = Reports::NominationsReport::MAPPING + expect(csv_content.headers.length).to eq(columns.length) + + columns.each do |column| + expect(csv_content.headers).to include(column[:label]) + end + end + + it 'renders the correct data' do + columns = Reports::NominationsReport::MAPPING + nomination = Reports::Nomination.new(form_answer) + columns.each do |column| + expect(csv_content[0][column[:label]]).to eq(nomination.call_method(column[:method]).to_s) + end + end + end +end