Skip to content

Commit

Permalink
chore: Refactor Reports::QavsBase#sanitize_string to use string.strip…
Browse files Browse the repository at this point in the history
… instead of string.to_s.tr("\n","").squish

Signed-off-by: Louis Kirkham <[email protected]>
  • Loading branch information
TheDancingClown committed Aug 8, 2024
1 parent 2d7e690 commit c88339d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/reports/qavs_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def headers

def sanitize_string(string)
if string.present?
ActionView::Base.full_sanitizer.sanitize(string.to_s.tr("\n","").squish)
ActionView::Base.full_sanitizer.sanitize(string.to_s.strip)
else
""
end
Expand Down
7 changes: 7 additions & 0 deletions spec/models/reports/nominations_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,12 @@
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

0 comments on commit c88339d

Please sign in to comment.