Skip to content
This repository was archived by the owner on Jul 24, 2020. It is now read-only.

Commit 2109c64

Browse files
committed
Merge pull request #1436 from YaleSTC/1433_email_fines_55
[1433] Fix incorrect e-mail variable replacement
2 parents 22490f7 + 500fb47 commit 2109c64

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
## v5.5.2 - 2016-01-18
66
### Fixed
77
* Resolved an issue where all AdminMailer e-mails were not being delivered ([#1426](https://github.com/YaleSTC/reservations/issues/1426)).
8+
* Resolved an issue where late fees in e-mails were cumulative, not daily ([#1433](https://github.com/YaleSTC/reservations/issues/1433)).
89

910
## v5.5.1 - 2016-01-12
1011
### Fixed

app/helpers/user_mailer_helper.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ def replace_variables(body)
77
body.gsub!('@equipment_list@', @reservation.equipment_model.name)
88
body.gsub!('@return_date@', @reservation.due_date.to_s(:long))
99
body.gsub!('@start_date@', @reservation.start_date.to_s(:long))
10-
body.gsub!('@late_fee@', number_to_currency(@reservation.late_fee))
10+
body.gsub!('@late_fee@',
11+
number_to_currency(@reservation.equipment_model.late_fee))
1112
body.gsub!('@replacement_fee@',
1213
number_to_currency(@reservation.equipment_model.replacement_fee))
1314
body.gsub!('@tos@', @app_configs.terms_of_service)
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
require 'spec_helper'
2+
3+
describe UserMailerHelper, type: :helper do
4+
before(:each) do
5+
@app_configs = double(department_name: 'dept', terms_of_service: 'tos')
6+
@reservation = double(id: 1, reserver: double(name: 'name'),
7+
equipment_model: double(name: 'em', late_fee: 100,
8+
replacement_fee: 200),
9+
start_date: Time.zone.today,
10+
due_date: Time.zone.today + 1.day)
11+
end
12+
13+
context '.replace_variables' do
14+
it 'returns an empty string when no body is passed' do
15+
expect(replace_variables(nil)).to eq('')
16+
end
17+
18+
it 'replaces @user@ with the reserver name' do
19+
expect(replace_variables('@user@')).to eq(@reservation.reserver.name)
20+
end
21+
22+
it 'replaces @reservation_id@ with the reservation id' do
23+
expect(replace_variables('@reservation_id@')).to eq(@reservation.id.to_s)
24+
end
25+
26+
it 'replaces @department_name@ with the department name' do
27+
expect(replace_variables('@department_name@')).to \
28+
eq(@app_configs.department_name)
29+
end
30+
31+
it 'replaces @equipment_list@ with the equipment model name' do
32+
expect(replace_variables('@equipment_list@')).to \
33+
eq(@reservation.equipment_model.name)
34+
end
35+
36+
it 'replaces @return_date@ with the due date' do
37+
expect(replace_variables('@return_date@')).to \
38+
eq(@reservation.due_date.to_s(:long))
39+
end
40+
41+
it 'replaces @start_date@ with the start date' do
42+
expect(replace_variables('@start_date@')).to \
43+
eq(@reservation.start_date.to_s(:long))
44+
end
45+
46+
it 'replaces @late_fee@ with the equipment model late fee rate' do
47+
expect(replace_variables('@late_fee@')).to \
48+
eq(number_to_currency(@reservation.equipment_model.late_fee))
49+
end
50+
51+
it 'replaces @replacement_fee@ with the equipment model replacement fee' do
52+
expect(replace_variables('@replacement_fee@')).to \
53+
eq(number_to_currency(@reservation.equipment_model.replacement_fee))
54+
end
55+
56+
it 'replaces @tos@ with the terms of service' do
57+
expect(replace_variables('@tos@')).to eq(@app_configs.terms_of_service)
58+
end
59+
end
60+
end

0 commit comments

Comments
 (0)