Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging < main #710

Merged
merged 7 commits into from
Aug 19, 2024
20 changes: 20 additions & 0 deletions app/models/reports/nomination.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 29 additions & 1 deletion app/models/reports/nominations_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,40 @@ 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

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
4 changes: 2 additions & 2 deletions forms/award_years/v2025/qavs/qavs_step2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:

<span class='indented'>- Give excellent service to their beneficiaries and communities</span>
<span class='indented'>- Deliver their service in innovative ways,</span>
<span class='indented'>- Show other examples of selfless voluntary service that distinguish their work.</span>
<span class='indented'>- Deliver their service in innovative ways</span>
<span class='indented'>- Show other examples of selfless voluntary service that distinguish their work</span>
</p>
<p class='govuk-body'>
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'.
Expand Down
38 changes: 38 additions & 0 deletions spec/models/reports/nominations_report_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Loading