diff --git a/app/assets/javascripts/ajax-links.js b/app/assets/javascripts/ajax-links.js
new file mode 100644
index 0000000..1dd5fac
--- /dev/null
+++ b/app/assets/javascripts/ajax-links.js
@@ -0,0 +1,16 @@
+function handleAjaxResponse($el) {
+ var $header = $('header');
+ $el.on("ajax:success", function(e, data){
+ $header.after('
' + data.message + '
');
+ }).on("ajax:error", function(e, xhr) {
+ if (xhr.status === 400){
+ $header.after('' + xhr.responseJSON.join('
') + '
');
+ } else {
+ $header.after('Oops! There was an error processing your request. Please try again.
');
+ }
+ });
+}
+
+$(document).ready(function() {
+ $('[data-id=ajax-action]').each(function(){ handleAjaxResponse($(this)); });
+});
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 9faf3dd..199376b 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -15,6 +15,8 @@
//= require turbolinks
//= require modernizr-lite/modernizr
+//= require ajax-links
+
//= require forms/button-group
//= require forms/animations
//= require forms/textarea-limit
diff --git a/app/assets/javascripts/summary-edit.js b/app/assets/javascripts/summary-edit.js
index 3dc0011..22ea2c2 100644
--- a/app/assets/javascripts/summary-edit.js
+++ b/app/assets/javascripts/summary-edit.js
@@ -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
*/
diff --git a/app/assets/stylesheets/core/_animations.scss b/app/assets/stylesheets/core/_animations.scss
index 8ac0eaa..2796ef2 100644
--- a/app/assets/stylesheets/core/_animations.scss
+++ b/app/assets/stylesheets/core/_animations.scss
@@ -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;
+ }
}
diff --git a/app/controllers/recruiter_controller.rb b/app/controllers/recruiter_controller.rb
index c736c29..4b6731e 100644
--- a/app/controllers/recruiter_controller.rb
+++ b/app/controllers/recruiter_controller.rb
@@ -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
diff --git a/app/views/candidate_mailer/welcome.html.inky b/app/views/candidate_mailer/welcome.html.inky
index 3137d9b..82a4191 100644
--- a/app/views/candidate_mailer/welcome.html.inky
+++ b/app/views/candidate_mailer/welcome.html.inky
@@ -15,4 +15,4 @@
Once we have evaluated your answers, your recruiter will be in touch. Good luck!
-
\ No newline at end of file
+
diff --git a/app/views/recruiter/index.html.erb b/app/views/recruiter/index.html.erb
index 128756d..86d8219 100644
--- a/app/views/recruiter/index.html.erb
+++ b/app/views/recruiter/index.html.erb
@@ -20,7 +20,11 @@
<%= candidate.name %> |
<%= candidate.test_hash %> |
- <%= mail_to(candidate.email) %> |
+
+ <%= mail_to(candidate.email) %>
+
+ <%= link_to "resend welcome email", resend_welcome_path(candidate.id), remote: true, class: '', data: { id: 'ajax-action' } %>
+ |
<%= candidate.experience %> years |
<%= candidate.status %> |
<%= candidate.completed ? "Submitted" : "" %> |
diff --git a/config/routes.rb b/config/routes.rb
index ca4a9dc..ed1aba5 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -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
diff --git a/test/controllers/recruiter_controller_test.rb b/test/controllers/recruiter_controller_test.rb
index dafd52e..e028d3f 100644
--- a/test/controllers/recruiter_controller_test.rb
+++ b/test/controllers/recruiter_controller_test.rb
@@ -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