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

add dedication contact details to receipt emails #962

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
22 changes: 21 additions & 1 deletion app/views/donation_mailer/_donation_payment_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,27 @@
<tr>
<td><strong>Dedication</strong></td>
<td> <%= donation.dedication ? Format::Dedication.from_json(donation.dedication) : 'None' %></td>

</tr>
<% @contact = JSON.parse(donation.dedication).dig('contact') %>
<tr>
<td><strong>Acknowledgement Email</strong></td>
<% if @contact && @contact['email'] %>
hejkal marked this conversation as resolved.
Show resolved Hide resolved
<td><a href="mailto:<%= @contact['email'] %>"><%= @contact['email'] %></a></td>
<% else %>
<td> None </td>
<% end %>
</tr>
<tr>
<td><strong>Acknowledgement Phone</strong></td>
<% if @contact && @contact['phone'] %>
<td><a href="tel:<%= @contact['phone'] %>"><%= @contact['phone'] %></a></td>
<% else %>
<td> None </td>
<% end %>
</tr>
<tr>
<td><strong>Acknowledgement Address</strong></td>
<td> <%= @contact && @contact['address'] ? @contact['address'] : 'None' %> </td>
</tr>
<% end %>

Expand Down
17 changes: 13 additions & 4 deletions spec/factories/donations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@
)]
}
end
end




factory :donation_with_dedication do
dedication { {
contact: {
email: '[email protected]',
phone: '234-343-3234',
address: '123 Four'
},
name: 'our loved one',
note: 'we miss them dearly',
type: 'memory'
}.to_json }
end
end

factory :fv_poverty_donation, class: 'Donation' do
nonprofit {association :fv_poverty}
Expand Down
42 changes: 40 additions & 2 deletions spec/mailers/donation_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,44 @@
expect(mail.subject).to include supporter.email
end
end


context 'when dedication is not set' do
before(:each) {
expect(QueryUsers).to receive(:nonprofit_user_emails).and_return(['[email protected]'])
}

let(:supporter) { create(:supporter_base)}
let(:donation) { create(:donation_base, supporter: supporter, nonprofit: supporter.nonprofit)}
let(:payment) { create(:payment_base, donation: donation)}

let!(:mail) { DonationMailer.nonprofit_payment_notification(
donation.id,
payment.id
) }

it 'does not include the dedication section' do
expect(mail.body.encoded).to_not include "Acknowledgement Phone"
end
end

context 'when dedication is set' do
before(:each) {
expect(QueryUsers).to receive(:nonprofit_user_emails).and_return(['[email protected]'])
}

let(:supporter) { create(:supporter_base)}
let(:donation) { create(:donation_with_dedication, supporter: supporter, nonprofit: supporter.nonprofit)}
let(:payment) { create(:payment_base, donation: donation)}

let!(:mail) { DonationMailer.nonprofit_payment_notification(
donation.id,
payment.id
) }

it 'does not include the dedication section' do
expect(mail.body.encoded).to include "Acknowledgement Phone"
expect(mail.body.encoded).to include "234-343-3234"
end
end
end
end
end
Loading