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..ba6ae9b41 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 @@ -72,4 +92,12 @@ class Reports::NominationsReport < Reports::QavsBase def mapping MAPPING end + + def sanitize_string(string) + if string.present? + ActionView::Base.full_sanitizer.sanitize(string.to_s.strip).gsub("\u00A0", "\u0020") + else + "" + end + end end diff --git a/forms/award_years/v2025/qavs/qavs_step2.rb b/forms/award_years/v2025/qavs/qavs_step2.rb index 3240c6a77..b0e1a598e 100644 --- a/forms/award_years/v2025/qavs/qavs_step2.rb +++ b/forms/award_years/v2025/qavs/qavs_step2.rb @@ -13,8 +13,8 @@ def qavs_step2 In this section, please explain how the nominated group has made a significant contribution in its area of activity. We are looking for groups that: - Give excellent service to their beneficiaries and communities - - Deliver their service in innovative ways, - - Show other examples of selfless voluntary service that distinguish their work. + - Deliver their service in innovative ways + - Show other examples of selfless voluntary service that distinguish their work
Please avoid using 'we' or 'our' in this section as this gives an indication that the person making the nomination is involved in the running of the group's work. It is recommended that you use 'their' or 'the group's work'. diff --git a/spec/models/reports/nominations_report_spec.rb b/spec/models/reports/nominations_report_spec.rb new file mode 100644 index 000000000..4ca5aebf7 --- /dev/null +++ b/spec/models/reports/nominations_report_spec.rb @@ -0,0 +1,38 @@ +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 + + it 'renders new lines' do + test_answer = "Line one\nLine two\nLine three" + form_answer.document[:group_activities] = test_answer + form_answer.save + expect(csv_content[0]["Please summarise the activities of the group"]).to eq(test_answer) + end + end +end