move /review to /admin/results
This commit is contained in:
parent
9078c463f4
commit
0a9bf96e24
21
app/controllers/admin/result_controller.rb
Normal file
21
app/controllers/admin/result_controller.rb
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
module Admin
|
||||||
|
class ResultController < AdminController
|
||||||
|
#
|
||||||
|
# TODO: change context from Candidate to Quiz
|
||||||
|
# bypass pundit lockdowns until completed
|
||||||
|
after_action :skip_policy_scope
|
||||||
|
after_action :skip_authorization
|
||||||
|
#
|
||||||
|
|
||||||
|
def index
|
||||||
|
@candidates = Candidate.where(completed: true).includes(:recruiter)
|
||||||
|
end
|
||||||
|
|
||||||
|
def view
|
||||||
|
@candidate = Candidate.find_by(test_hash: params[:test_hash])
|
||||||
|
@quiz = @candidate.my_quiz
|
||||||
|
@status = QuizStatus.new(@candidate)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -1,34 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
class ReviewController < ApplicationController
|
|
||||||
before_action :authorize_reviewer, except: [:login, :auth]
|
|
||||||
|
|
||||||
def index
|
|
||||||
@candidates = Candidate.where(completed: true).includes(:recruiter)
|
|
||||||
end
|
|
||||||
|
|
||||||
def view
|
|
||||||
@candidate = Candidate.find_by(test_hash: params[:test_hash])
|
|
||||||
@quiz = @candidate.my_quiz
|
|
||||||
@status = QuizStatus.new(@candidate)
|
|
||||||
end
|
|
||||||
|
|
||||||
def login
|
|
||||||
redirect_to review_path unless current_reviewer.nil?
|
|
||||||
end
|
|
||||||
|
|
||||||
def auth
|
|
||||||
reviewer = User.find_by(email: auth_params[:email], role: %w(admin reviewer))
|
|
||||||
|
|
||||||
if reviewer && reviewer.authenticate(auth_params[:password])
|
|
||||||
session[:user] = reviewer.to_i
|
|
||||||
redirect_to review_path
|
|
||||||
else
|
|
||||||
redirect_to review_login_path, flash: { error: "Sorry, incorrect email or password. Please try again." }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def logout
|
|
||||||
reset_session
|
|
||||||
redirect_to review_login_path
|
|
||||||
end
|
|
||||||
end
|
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<% @candidates.each do |candidate| %>
|
<% @candidates.each do |candidate| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to candidate.test_hash, review_test_path(candidate.test_hash) %></td>
|
<td><%= link_to candidate.test_hash, admin_result_path(candidate.test_hash) %></td>
|
||||||
<td><%= candidate.experience %> years</td>
|
<td><%= candidate.experience %> years</td>
|
||||||
<td><%= mail_to(candidate.recruiter.email) %></td>
|
<td><%= mail_to(candidate.recruiter.email) %></td>
|
||||||
</tr>
|
</tr>
|
@ -27,7 +27,7 @@
|
|||||||
<% end #form_tag %>
|
<% end #form_tag %>
|
||||||
<% end #questions loop %>
|
<% end #questions loop %>
|
||||||
|
|
||||||
<%= link_to(review_path, { class: 'secondary-btn' }) do %>
|
<%= link_to(admin_results_path, { class: 'secondary-btn' }) do %>
|
||||||
<button>Back to list</button>
|
<button>Back to list</button>
|
||||||
<% end %>
|
<% end %>
|
||||||
</main>
|
</main>
|
@ -1,21 +0,0 @@
|
|||||||
<main class="intro_tpl">
|
|
||||||
<h1>Reviewer Login</h1>
|
|
||||||
|
|
||||||
<% if flash[:error].present? %>
|
|
||||||
<div class="error"><%= flash[:error] %></div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= form_for :auth, url: review_login_path do |form| %>
|
|
||||||
<div class="form-group">
|
|
||||||
<%= form.label :email %>
|
|
||||||
<%= form.email_field :email %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<%= form.label :password %>
|
|
||||||
<%= form.password_field :password %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%= submit_tag "Login" %>
|
|
||||||
<% end %>
|
|
||||||
</main>
|
|
@ -1,6 +1,6 @@
|
|||||||
<row>
|
<row>
|
||||||
<columns class="email-body">
|
<columns class="email-body">
|
||||||
<p>Candidate <strong><%= @candidate.test_hash %></strong> has completed the Skills Assessment Test.</p>
|
<p>Candidate <strong><%= @candidate.test_hash %></strong> has completed the Skills Assessment Test.</p>
|
||||||
<p>You can view the results here: <%= link_to nil, review_test_url(@candidate.test_hash) %>.</p>
|
<p>You can view the results here: <%= link_to nil, admin_result_url(@candidate.test_hash) %>.</p>
|
||||||
</columns>
|
</columns>
|
||||||
</row>
|
</row>
|
||||||
|
@ -2,4 +2,4 @@ PERFICIENT/digital SKILLS ASSESSMENT RESULTS
|
|||||||
|
|
||||||
Candidate <%= @candidate.test_hash %> has completed the Skills Assessment Test.
|
Candidate <%= @candidate.test_hash %> has completed the Skills Assessment Test.
|
||||||
|
|
||||||
You can view the results here: <%= review_test_url(@candidate.test_hash) %>.
|
You can view the results here: <%= admin_result_url(@candidate.test_hash) %>.
|
||||||
|
@ -47,11 +47,8 @@ Rails.application.routes.draw do
|
|||||||
post "/admin/candidate/:id", to: "admin/candidate#update", as: :admin_update_candidate
|
post "/admin/candidate/:id", to: "admin/candidate#update", as: :admin_update_candidate
|
||||||
get "/admin/candidate/:id/resend", to: "admin/candidate#resend_welcome", as: :admin_resend_welcome
|
get "/admin/candidate/:id/resend", to: "admin/candidate#resend_welcome", as: :admin_resend_welcome
|
||||||
|
|
||||||
get "/review/logout", to: "review#logout", as: :review_logout
|
get "/admin/results", to: "admin/result#index", as: :admin_results
|
||||||
post "/review/login", to: "review#auth", as: :review_auth
|
get "/admin/result/:test_hash", to: "admin/result#view", as: :admin_result
|
||||||
get "/review/login", to: "review#login", as: :review_login
|
|
||||||
get "/review", to: "review#index", as: :review
|
|
||||||
get "/review/:test_hash", to: "review#view", as: :review_test
|
|
||||||
|
|
||||||
get "/admin", to: "admin/dashboard#show", as: :admin
|
get "/admin", to: "admin/dashboard#show", as: :admin
|
||||||
|
|
||||||
|
23
test/controllers/admin/result_controller_test.rb
Normal file
23
test/controllers/admin/result_controller_test.rb
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
module Admin
|
||||||
|
class ResultControllerTest < ActionDispatch::IntegrationTest
|
||||||
|
test "should get results list" do
|
||||||
|
auth_reviewer
|
||||||
|
get admin_results_url
|
||||||
|
assert_response :success
|
||||||
|
assert assigns(:candidates), '@candidates not present'
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should get view" do
|
||||||
|
auth_reviewer
|
||||||
|
|
||||||
|
get admin_result_url(candidates(:richard).test_hash)
|
||||||
|
assert_response :success
|
||||||
|
assert assigns(:candidate), "@candidate not present"
|
||||||
|
assert assigns(:quiz), "@quiz not present"
|
||||||
|
assert assigns(:status), "@status not present"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -1,63 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
require 'test_helper'
|
|
||||||
|
|
||||||
class ReviewControllerTest < ActionDispatch::IntegrationTest
|
|
||||||
test "should get login" do
|
|
||||||
get review_login_url
|
|
||||||
assert_response :success
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should require auth or redirect" do
|
|
||||||
get review_url
|
|
||||||
assert_redirected_to review_login_path
|
|
||||||
|
|
||||||
get review_test_url(candidates(:richard).test_hash)
|
|
||||||
assert_redirected_to review_login_path
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should auth to index" do
|
|
||||||
auth_reviewer
|
|
||||||
assert_redirected_to admin_path
|
|
||||||
assert session[:user].present?
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should fail auth with flash" do
|
|
||||||
post review_auth_url, params: { auth:
|
|
||||||
{ email: 'fed.review@mailinator.com', password: 'bad-password' } }
|
|
||||||
|
|
||||||
assert_redirected_to review_login_path
|
|
||||||
assert flash[:error]
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should get review list" do
|
|
||||||
auth_reviewer
|
|
||||||
get review_url
|
|
||||||
assert_response :success
|
|
||||||
assert assigns(:candidates), '@candidates not present'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should get index" do
|
|
||||||
auth_reviewer
|
|
||||||
|
|
||||||
get review_url
|
|
||||||
assert_response :success
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should get view" do
|
|
||||||
auth_reviewer
|
|
||||||
|
|
||||||
get review_test_url(candidates(:richard).test_hash)
|
|
||||||
assert_response :success
|
|
||||||
assert assigns(:candidate), "@candidate not present"
|
|
||||||
assert assigns(:quiz), "@quiz not present"
|
|
||||||
assert assigns(:status), "@status not present"
|
|
||||||
end
|
|
||||||
|
|
||||||
test 'should logout and reset session' do
|
|
||||||
auth_reviewer
|
|
||||||
get review_logout_path
|
|
||||||
|
|
||||||
assert :success
|
|
||||||
assert session[:user].nil?
|
|
||||||
end
|
|
||||||
end
|
|
@ -20,10 +20,9 @@ class QuestionAttachmentsTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "should show attachments on review" do
|
test "should show attachments on review" do
|
||||||
user = users :reviewer
|
auth_reviewer
|
||||||
post review_auth_url, params: { auth: { email: user.email, password: 'password' } }
|
|
||||||
|
|
||||||
get review_test_path(candidates(:richard).test_hash)
|
get admin_result_path(candidates(:richard).test_hash)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select "img[src=\"#{questions(:fed6).attachment}\"]"
|
assert_select "img[src=\"#{questions(:fed6).attachment}\"]"
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user