Permalink
Browse files

added email notifications when posting and applaying for a job

  • Loading branch information...
1 parent df546a2 commit 8df1d9424013a4d27d2b617f4c1ed447671ecf43 Ivan Acosta-Rubio committed Jul 10, 2008
@@ -29,6 +29,7 @@ def apply
@job_applicant = @job.job_applicants.build(params[:job_applicant])
if @job_applicant.save
session[:applied_id] = @job.id
+ Notifier::deliver_somebodyapplied(@job.poster_email,@job_applicant.name, @job_applicant.message, @job_applicant.filename, @job_applicant.id)
redirect_to job_url(@job)
else
render :action => "show"
@@ -99,6 +100,8 @@ def create
flash[:notice] = 'Job was successfully created.'
format.html { redirect_to verify_job_url(@job) }
format.xml { render :xml => @job, :status => :created, :location => @job }
+ Notifier::deliver_jobposted(@job.poster_email,@job.company)
+
else
format.html { render :action => "new" }
format.xml { render :xml => @job.errors, :status => :unprocessable_entity }
View
@@ -0,0 +1,28 @@
+class Notifier < ActionMailer::Base
+
+
+ def jobposted(recipient, company, sent_at = Time.now)
+ subject 'thanks for posting'
+ recipients recipient
+ from 'jobs@'
+ sent_on sent_at
+ content_type "multipart/alternative"
+
+ part :content_type => "text/plain",
+ :body => render_message("jobposted", :company => company)
+
+ end
+
+ def somebodyapplied(recipient, name, message, filename, id, sent_at = Time.now)
+ subject 'somebody applied'
+ recipients recipient
+ from 'jobs@'
+ sent_on sent_at
+ content_type "multipart/alternative"
+
+ part :content_type => "text/plain",
+ :body => render_message("somebodyapplied", :name => name, :message => message, :filename => filename, :id => id)
+
+ end
+
+end
@@ -0,0 +1,5 @@
+Hello <%= @company %>!,
+
+Thank you for posting a new job opening.
+
+We'll be in touch when somebody applies.
@@ -0,0 +1,11 @@
+Hello there,
+
+Somebody just applied to your job opening.
+
+------------------------------------------
+
+Name: <%= @name %>
+
+Message: <%= @message %>
+
+------------------------------------------
View
@@ -19,4 +19,4 @@ production:
adapter: mysql
database: jobberrails_production
host: localhost
- user: root
+ user: root
@@ -0,0 +1,3 @@
+Notifier#jobposted
+
+Find me in app/views/notifier/jobposted.erb
@@ -0,0 +1,3 @@
+Notifier#somebodyapplied
+
+Find me in app/views/notifier/somebodyapplied.erb
View
@@ -0,0 +1,21 @@
+require 'test_helper'
+
+class NotifierTest < ActionMailer::TestCase
+ tests Notifier
+ def test_jobposted
+ @expected.subject = 'Notifier#jobposted'
+ @expected.body = read_fixture('jobposted')
+ @expected.date = Time.now
+
+ assert_equal @expected.encoded, Notifier.create_jobposted(@expected.date).encoded
+ end
+
+ def test_somebodyapplied
+ @expected.subject = 'Notifier#somebodyapplied'
+ @expected.body = read_fixture('somebodyapplied')
+ @expected.date = Time.now
+
+ assert_equal @expected.encoded, Notifier.create_somebodyapplied(@expected.date).encoded
+ end
+
+end

0 comments on commit 8df1d94

Please sign in to comment.