Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/workshop_invitation_mailer/attending.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
- if @workshop.description.present?
%p{ style: 'margin-top: 10px;' }
%strong Description:
= @workshop.description
= sanitize(@workshop.description)

.content
%table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
- if @workshop.description.present?
%p{ style: 'margin-top: 10px;' }
%strong Description:
= @workshop.description
= sanitize(@workshop.description)

.content
%table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
- if @workshop.description.present?
%p{ style: 'margin-top: 15px;' }
%strong Description:
= @workshop.description
= sanitize(@workshop.description)
%td{ width: '40%', style: 'vertical-align: top;'}
%h4
Venue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
- if @workshop.description.present?
%p{ style: 'margin-top: 15px;' }
%strong Description:
= @workshop.description
= sanitize(@workshop.description)
%td{ width: '40%', style: 'vertical-align: top;'}
%h4
Venue
Expand Down
7 changes: 4 additions & 3 deletions spec/mailers/virtual_workshop_invitation_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@
expect(email.body.encoded).to match('Accept the invitation')
end

it '#attending includes the workshop description' do
description = "This is a test workshop description."
it '#attending renders workshop description as HTML, not escaped' do
description = '<strong>Important notice:</strong> Please bring a laptop.'
workshop = Fabricate(:workshop, description: description)
invitation = Fabricate(:workshop_invitation, workshop: workshop, member: member)

WorkshopInvitationMailer.attending(workshop, member, invitation).deliver_now

expect(email.body.encoded).to include(description)
expect(email.body.encoded).to include('Please bring a laptop.')
expect(email.body.encoded).not_to include('&lt;strong&gt;Important')
end

it '#invite_coach' do
Expand Down
7 changes: 4 additions & 3 deletions spec/mailers/workshop_invitation_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,14 @@
expect(email.body.encoded).to match(workshop.chapter.email)
end

it '#attending includes the workshop description' do
description = "This is a test workshop description."
it '#attending renders workshop description as HTML, not escaped' do
description = '<strong>Important notice:</strong> Please bring a laptop.'
workshop = Fabricate(:workshop, description: description)
invitation = Fabricate(:workshop_invitation, workshop: workshop, member: member)

WorkshopInvitationMailer.attending(workshop, member, invitation).deliver_now

expect(email.body.encoded).to include(description)
expect(email.body.encoded).to include('Please bring a laptop.')
expect(email.body.encoded).not_to include('&lt;strong&gt;Important')
end
end
3 changes: 2 additions & 1 deletion spec/presenters/address_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

describe '#to_html' do
it 'returns the address in HTML with lines separated with <br/> tags' do
html_address = "#{address.flat}<br/>#{address.street}<br/>#{address.city}, #{address.postal_code}"
escape = ERB::Util.method(:html_escape)
html_address = "#{escape.call(address.flat)}<br/>#{escape.call(address.street)}<br/>#{escape.call(address.city)}, #{escape.call(address.postal_code)}"

expect(presenter.to_html).to eq(html_address)
end
Expand Down