Skip to content

Commit

Permalink
include PUBLIC_COMMENT in mail template substitution (closes #8)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwolfst committed Aug 4, 2016
1 parent 4d70ff8 commit eb254e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/rawbotz/mail_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module MailTemplate
def self.consume template, order
result = ""
result = template.gsub(/SUPPLIERNAME/, order.supplier[:name])
result = result.gsub(/PUBLIC_COMMENT/, order.public_comment || "")

lines = result.split("\n")
subject, lines = lines.partition{|l| l.start_with?("SUBJECT=")}
Expand Down
4 changes: 3 additions & 1 deletion test/mail_template_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ def test_substitution
"\n"\
" \n"\
"* SUPPLIERSKU QTY (NUM_PACKS of PACKSIZE) PRODUCTNAME\n"\
"PUBLIC_COMMENT\n"\
"see you"
order = {supplier: {name: "Suppliername"}, order_items: [
OI_BARE, OI_FULL, OI_HALF]}
OI_BARE, OI_FULL, OI_HALF], public_comment: "Call me when finished"}
order = OpenStruct.new order

expected = "Dear Suppliername\n"\
Expand All @@ -29,6 +30,7 @@ def test_substitution
" 1 (0.25 of 4) First Product\n"\
"sku1 5 (1 of 5) Suppliers first\n"\
" 7 ( of ) Third Product\n"\
"Call me when finished\n"\
"see you"
result = Rawbotz::MailTemplate.consume(template, order)
assert_equal expected, result
Expand Down

0 comments on commit eb254e2

Please sign in to comment.