Permalink
Browse files

unit testing for email

  • Loading branch information...
Ivan Acosta-Rubio Ivan Acosta-Rubio
Ivan Acosta-Rubio authored and Ivan Acosta-Rubio committed Jul 12, 2008
1 parent 6ccd6ec commit 4f4b2562e9758d63b6aef22bee0bbdb83168c9c2
@@ -14,6 +14,7 @@ def create
flash[:notice] = "You are logged as #{admin.login}"
redirect_to admin_url
else
session[:admin] = admin
flash[:error] = "Invalid login or password!"
redirect_to login_url
end
View
@@ -27,18 +27,19 @@
end
create_table "job_applicants", :force => true do |t|
t.integer "job_id", :limit => 11
t.integer "job_id", :limit => 11
t.string "name"
t.string "email"
t.string "message"
t.string "ip"
t.string "content_type"
t.string "filename"
t.string "thumbnail"
t.integer "size", :limit => 11
t.integer "width", :limit => 11
t.integer "height", :limit => 11
t.datetime "created_at"
t.datetime "updated_at"
t.string "integer"
t.string "resume_file_name"
t.string "resume_file_size"
t.string "resume_content_type"
t.string "string"
end
create_table "job_hunters", :force => true do |t|
@@ -1 +1 @@
JOB POSTED EMAIL
FIXTURESSSSSSSS
@@ -1 +1,11 @@
SOMEBODY APPLIED EMAIL
Hello there,
Somebody just applied to your job opening.
------------------------------------------
Name: <%= @name %>
Message: <%= @message %>
------------------------------------------
@@ -1,4 +1,4 @@
require 'test_helper'
require 'test/test_helper'
class JobsControllerTest < ActionController::TestCase
def test_should_get_index
@@ -1,4 +1,4 @@
require 'test_helper'
require 'test/test_helper'
class SessionsControllerTest < ActionController::TestCase
@@ -1,4 +1,4 @@
require 'test_helper'
require 'test/test_helper'
class AdministrativePanelTest < ActionController::IntegrationTest
View
@@ -1,27 +1,54 @@
require 'test_helper'
require 'test/test_helper'
require 'notifier'
class NotifierTest < Test::Unit::TestCase
CHARSET = "utf-8"
class NotifierTest < ActionMailer::TestCase
tests Notifier
def test_assert_truth
assert true
include ActionMailer::Quoting
def setup
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.deliveries = []
@expected = TMail::Mail.new
@expected.set_content_type "text", "plain", { "charset" => CHARSET }
end
# TODO: fix these tests
# def test_job_posted
# @expected.subject = "#{AppConfig.site_name} - Thanks for Posting"
# @expected.body = read_fixture('job_posted')
# @expected.date = Time.now
#
# assert_equal @expected.encoded, Notifier.create_job_posted(@expected.date).encoded
# end
#
# def test_somebody_applied
# @expected.subject = "#{AppConfig.site_name} - New Job Applicant"
# @expected.body = read_fixture('somebody_applied')
# @expected.date = Time.now
#
# assert_equal @expected.encoded, Notifier.create_somebody_applied(@expected.date).encoded
# end
def test_job_posted
recipient = "#{AppConfig.from_email}"
company = 'jobberRails'
response = Notifier.deliver_job_posted(recipient,company)
assert_equal "#{AppConfig.site_name} - Thanks for Posting", response.subject
assert_match "Hello jobberRails!,\n\nThank you for posting a new job opening. \n\nWe'll be in touch when somebody applies.", response.body
assert_equal "jobberrails@gmail.com", response.to[0]
end
def test_somebody_applied
recipient = "#{AppConfig.from_email}"
company = 'jobberRails'
message = "New Job Applicant"
filename = "filename"
id = "3"
sent_at = Time.now
response = Notifier.deliver_somebody_applied(recipient,name,message,filename,id,sent_at)
assert_equal "#{AppConfig.site_name} - New Job Applicant", response.subject
assert_equal "jobberrails@gmail.com", response.to[0]
assert response.body =~ /New Job Applicant/
end
private
def read_fixture(action)
IO.readlines("#{action}")
end
end

0 comments on commit 4f4b256

Please sign in to comment.