adopt-a-hydrant/test/functional/reminders_controller_test.rb

28 lines
1019 B
Ruby
Raw Normal View History

require 'test_helper'
class RemindersControllerTest < ActionController::TestCase
2012-06-18 17:49:28 +00:00
include Devise::TestHelpers
2011-06-29 19:04:49 +00:00
setup do
2012-06-18 17:49:28 +00:00
request.env["devise.mapping"] = Devise.mappings[:user]
@thing = things(:thing_1)
2011-06-29 19:04:49 +00:00
@dan = users(:dan)
2012-06-18 17:49:28 +00:00
@user = users(:erik)
@thing.user = @dan
@thing.save!
2012-11-15 16:56:00 +00:00
stub_request(:get, "http://maps.google.com/maps/geo").
2013-12-02 11:37:18 +00:00
with(query: {key: "REPLACE_WITH_YOUR_GOOGLE_KEY", ll: "42.383339,-71.049226", oe: "utf-8", output: "xml"}).
2012-11-15 16:56:00 +00:00
to_return(body: File.read(File.expand_path('../../fixtures/geo.kml', __FILE__)))
2011-06-29 19:04:49 +00:00
end
test 'should send a reminder email' do
2012-06-18 17:49:28 +00:00
sign_in @user
2011-06-29 19:04:49 +00:00
num_deliveries = ActionMailer::Base.deliveries.size
2012-06-18 17:49:28 +00:00
post :create, format: :json, reminder: {thing_id: @thing.id, to_user_id: @dan.id}
2011-06-29 19:04:49 +00:00
assert_equal num_deliveries + 1, ActionMailer::Base.deliveries.size
assert_response :success
email = ActionMailer::Base.deliveries.last
assert_equal [@dan.email], email.to
2012-06-18 17:49:28 +00:00
assert_equal 'Remember to shovel', email.subject
2011-06-29 19:04:49 +00:00
end
end