Skip to content

Commit 5f7be46

Browse files
zacckjoshsmith
authored andcommitted
Add get_name function to the BaseEmail
1 parent 15d84db commit 5f7be46

File tree

6 files changed

+32
-9
lines changed

6 files changed

+32
-9
lines changed

emails/receipt.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<img src="{{high_five_image_url}}" width="100" height="100" />
4646
</p>
4747
<p class="donation_text center">
48-
<strong>{{user_first_name}}</strong>, thanks for your monthly donation to <a href="{{project_url}}">{{project_title}}</a>.
48+
Hey {{name}}, thanks for your monthly donation to <a href="{{project_url}}">{{project_title}}</a>.
4949
</p>
5050
<tr>
5151
<td class="donation_goal">

lib/code_corps/emails/base_email.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
defmodule CodeCorps.Emails.BaseEmail do
22
import Bamboo.Email, only: [from: 2, new_email: 0]
3+
alias CodeCorps.User
34

45
@spec create :: Bamboo.Email.t
56
def create do
67
new_email()
78
|> from("Code Corps<team@codecorps.org>")
89
end
10+
11+
@spec get_name(User.t) :: String.t
12+
def get_name(%User{first_name: nil}), do: "there"
13+
def get_name(%User{first_name: name}), do: name
914
end

lib/code_corps/emails/receipt_email.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ defmodule CodeCorps.Emails.ReceiptEmail do
5151
charge_amount: charge.amount |> format_amount(),
5252
charge_statement_descriptor: charge.statement_descriptor,
5353
high_five_image_url: high_five_image_url(),
54+
name: BaseEmail.get_name(charge.user),
5455
project_current_donation_goal_description: current_donation_goal.description,
5556
project_title: project.title,
5657
project_url: project |> url(),
57-
subject: project |> build_subject_line(),
58-
user_first_name: charge.user.first_name
58+
subject: project |> build_subject_line()
5959
}
6060
end
6161

priv/repo/structure.sql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
-- PostgreSQL database dump
33
--
44

5-
-- Dumped from database version 10.0
6-
-- Dumped by pg_dump version 10.0
5+
-- Dumped from database version 10.1
6+
-- Dumped by pg_dump version 10.1
77

88
SET statement_timeout = 0;
99
SET lock_timeout = 0;
@@ -166,7 +166,8 @@ CREATE TABLE conversation_parts (
166166
author_id bigint,
167167
conversation_id bigint,
168168
inserted_at timestamp without time zone NOT NULL,
169-
updated_at timestamp without time zone NOT NULL
169+
updated_at timestamp without time zone NOT NULL,
170+
part_type character varying(255) DEFAULT 'comment'::character varying
170171
);
171172

172173

@@ -4158,5 +4159,5 @@ ALTER TABLE ONLY users
41584159
-- PostgreSQL database dump complete
41594160
--
41604161

4161-
INSERT INTO "schema_migrations" (version) VALUES (20160723215749), (20160804000000), (20160804001111), (20160805132301), (20160805203929), (20160808143454), (20160809214736), (20160810124357), (20160815125009), (20160815143002), (20160816020347), (20160816034021), (20160817220118), (20160818000944), (20160818132546), (20160820113856), (20160820164905), (20160822002438), (20160822004056), (20160822011624), (20160822020401), (20160822044612), (20160830081224), (20160830224802), (20160911233738), (20160912002705), (20160912145957), (20160918003206), (20160928232404), (20161003185918), (20161019090945), (20161019110737), (20161020144622), (20161021131026), (20161031001615), (20161121005339), (20161121014050), (20161121043941), (20161121045709), (20161122015942), (20161123081114), (20161123150943), (20161124085742), (20161125200620), (20161126045705), (20161127054559), (20161205024856), (20161207112519), (20161209192504), (20161212005641), (20161214005935), (20161215052051), (20161216051447), (20161218005913), (20161219160401), (20161219163909), (20161220141753), (20161221085759), (20161226213600), (20161231063614), (20170102130055), (20170102181053), (20170104113708), (20170104212623), (20170104235423), (20170106013143), (20170115035159), (20170115230549), (20170121014100), (20170131234029), (20170201014901), (20170201025454), (20170201035458), (20170201183258), (20170220032224), (20170224233516), (20170226050552), (20170228085250), (20170308214128), (20170308220713), (20170308222552), (20170313130611), (20170318032449), (20170318082740), (20170324194827), (20170424215355), (20170501225441), (20170505224222), (20170526095401), (20170602000208), (20170622205732), (20170626231059), (20170628092119), (20170628213609), (20170629183404), (20170630140136), (20170706132431), (20170707213648), (20170711122252), (20170717092127), (20170725060612), (20170727052644), (20170731130121), (20170814131722), (20170913114958), (20170921014405), (20170925214512), (20170925230419), (20170926134646), (20170927100300), (20170928234412), (20171003134956), (20171003225853), (20171006063358), (20171006161407), (20171012215106), (20171012221231), (20171016125229), (20171016125516), (20171016223356), (20171016235656), (20171017235433), (20171019191035), (20171025184225), (20171026010933), (20171027061833), (20171028011642), (20171028173508), (20171030182857), (20171031232023), (20171031234356), (20171101023309), (20171104013543), (20171106045740), (20171106050209), (20171106103153), (20171106200036), (20171109231538), (20171110001134), (20171114010851), (20171114033357), (20171114225214), (20171114225713), (20171114232534), (20171115201624), (20171115225358), (20171119004204), (20171121075226), (20171121144138), (20171123065902), (20171127215847), (20171201073818), (20171205161052), (20171213062707);
4162+
INSERT INTO "schema_migrations" (version) VALUES (20160723215749), (20160804000000), (20160804001111), (20160805132301), (20160805203929), (20160808143454), (20160809214736), (20160810124357), (20160815125009), (20160815143002), (20160816020347), (20160816034021), (20160817220118), (20160818000944), (20160818132546), (20160820113856), (20160820164905), (20160822002438), (20160822004056), (20160822011624), (20160822020401), (20160822044612), (20160830081224), (20160830224802), (20160911233738), (20160912002705), (20160912145957), (20160918003206), (20160928232404), (20161003185918), (20161019090945), (20161019110737), (20161020144622), (20161021131026), (20161031001615), (20161121005339), (20161121014050), (20161121043941), (20161121045709), (20161122015942), (20161123081114), (20161123150943), (20161124085742), (20161125200620), (20161126045705), (20161127054559), (20161205024856), (20161207112519), (20161209192504), (20161212005641), (20161214005935), (20161215052051), (20161216051447), (20161218005913), (20161219160401), (20161219163909), (20161220141753), (20161221085759), (20161226213600), (20161231063614), (20170102130055), (20170102181053), (20170104113708), (20170104212623), (20170104235423), (20170106013143), (20170115035159), (20170115230549), (20170121014100), (20170131234029), (20170201014901), (20170201025454), (20170201035458), (20170201183258), (20170220032224), (20170224233516), (20170226050552), (20170228085250), (20170308214128), (20170308220713), (20170308222552), (20170313130611), (20170318032449), (20170318082740), (20170324194827), (20170424215355), (20170501225441), (20170505224222), (20170526095401), (20170602000208), (20170622205732), (20170626231059), (20170628092119), (20170628213609), (20170629183404), (20170630140136), (20170706132431), (20170707213648), (20170711122252), (20170717092127), (20170725060612), (20170727052644), (20170731130121), (20170814131722), (20170913114958), (20170921014405), (20170925214512), (20170925230419), (20170926134646), (20170927100300), (20170928234412), (20171003134956), (20171003225853), (20171006063358), (20171006161407), (20171012215106), (20171012221231), (20171016125229), (20171016125516), (20171016223356), (20171016235656), (20171017235433), (20171019191035), (20171025184225), (20171026010933), (20171027061833), (20171028011642), (20171028173508), (20171030182857), (20171031232023), (20171031234356), (20171101023309), (20171104013543), (20171106045740), (20171106050209), (20171106103153), (20171106200036), (20171109231538), (20171110001134), (20171114010851), (20171114033357), (20171114225214), (20171114225713), (20171114232534), (20171115201624), (20171115225358), (20171119004204), (20171121075226), (20171121144138), (20171123065902), (20171127215847), (20171201073818), (20171205161052), (20171213062707), (20171220154922);
41624163

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
defmodule CodeCorps.Emails.BaseEmailTest do
2+
use CodeCorps.ModelCase
3+
use Bamboo.Test
4+
alias CodeCorps.Emails.BaseEmail
5+
6+
describe "get_name/1" do
7+
test "get_name returns there on nil name" do
8+
user = %CodeCorps.User{}
9+
assert BaseEmail.get_name(user) == "there"
10+
end
11+
12+
test "get_name returns first_name of user" do
13+
user = %CodeCorps.User{first_name: "Zacck"}
14+
assert BaseEmail.get_name(user) == "Zacck"
15+
end
16+
end
17+
end

test/lib/code_corps/emails/receipt_email_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ defmodule CodeCorps.Emails.ReceiptEmailTest do
4646
assert template_model == %{
4747
charge_amount: "$5.00",
4848
charge_statement_descriptor: "Test descriptor",
49+
name: "Jimmy",
4950
project_title: "Code Corps",
5051
project_url: "http://localhost:4200/#{project.organization.slug}/#{project.slug}",
5152
project_current_donation_goal_description: "Test goal",
52-
subject: "Your monthly donation to Code Corps",
53-
user_first_name: "Jimmy"
53+
subject: "Your monthly donation to Code Corps"
5454
}
5555
assert high_five_image_url
5656
end

0 commit comments

Comments
 (0)