recruiter Resend welcome email

This commit is contained in:
Mark Moser 2016-09-15 10:01:31 -05:00
parent 9884748cf9
commit 372e86507e
9 changed files with 70 additions and 6 deletions

View File

@ -0,0 +1,16 @@
function handleAjaxResponse($el) {
var $header = $('header');
$el.on("ajax:success", function(e, data){
$header.after('<div class="success">' + data.message + '</div>');
}).on("ajax:error", function(e, xhr) {
if (xhr.status === 400){
$header.after('<div class="error">' + xhr.responseJSON.join('<br>') + '</div>');
} else {
$header.after('<div class="error">Oops! There was an error processing your request. Please try again.</div>');
}
});
}
$(document).ready(function() {
$('[data-id=ajax-action]').each(function(){ handleAjaxResponse($(this)); });
});

View File

@ -15,6 +15,8 @@
//= require turbolinks
//= require modernizr-lite/modernizr
//= require ajax-links
//= require forms/button-group
//= require forms/animations
//= require forms/textarea-limit

View File

@ -1,5 +1,5 @@
/* global updateResults */
/* TODO: remove global ^ once live-coder is properly name spaced */
// TODO: remove global ^ once live-coder is properly name spaced
/**
* Summary Page Answer Editor
*/

View File

@ -1,5 +1,28 @@
@keyframes success-fadeout {
0% { opacity: 1; max-height: 40px; }
85% { opacity: 0; max-height: 40px; padding: .5rem 0; margin-bottom: .5rem; }
100% { opacity: 0; max-height: 0; padding: 0; margin-bottom: 0; }
0% {
max-height: 40px;
opacity: 1;
}
85% {
margin-bottom: .5rem;
max-height: 40px;
opacity: 0;
padding: .5rem 0;
}
96% {
margin-bottom: 0;
max-height: 0;
opacity: 0;
padding: 0;
}
100% {
height: 0;
left: -10px;
position: absolute;
top: -10px;
width: 0;
}
}

View File

@ -45,6 +45,12 @@ class RecruiterController < ApplicationController
redirect_to recruiter_login_path
end
def resend_welcome
candidate = Candidate.find_by(id: params[:id])
CandidateMailer.welcome(candidate).deliver_later
render json: { message: "Email queued!" }.to_json
end
private
def candidate_params

View File

@ -15,4 +15,4 @@
Once we have evaluated your answers, your recruiter will be in touch. Good luck!
</p>
</columns>
</row>
</row>

View File

@ -20,7 +20,11 @@
<tr>
<td><%= candidate.name %></td>
<td><%= candidate.test_hash %></td>
<td><%= mail_to(candidate.email) %></td>
<td>
<%= mail_to(candidate.email) %>
<br />
<%= link_to "resend welcome email", resend_welcome_path(candidate.id), remote: true, class: '', data: { id: 'ajax-action' } %>
</td>
<td><%= candidate.experience %> years</td>
<td><%= candidate.status %></td>
<td><%= candidate.completed ? "Submitted" : "" %></td>

View File

@ -60,6 +60,8 @@ Rails.application.routes.draw do
get "/review", to: "review#index", as: :review
get "/review/:test_hash", to: "review#view", as: :review_test
get "/resend/welcome/:id", to: "recruiter#resend_welcome", as: :resend_welcome
get "/recruiter", to: "recruiter#index", as: :recruiter
get "/recruiter/new-candidate", to: "recruiter#new", as: :new_candidate
post "/recruiter/new-candidate", to: "recruiter#create", as: :create_candidate

View File

@ -102,4 +102,15 @@ class RecruiterControllerTest < ActionDispatch::IntegrationTest
assert assigns(:candidate), "@candidate not present"
assert_match(/failed.*save/i, flash[:error])
end
test 'should queue up a welcome email [resend]' do
auth_recruiter
assert_enqueued_jobs 1 do
get resend_welcome_path(id: candidates(:peggy)), xhr: true
end
assert_response :success
data = JSON.parse(response.body)
assert_match 'queued', data["message"]
end
end