diff --git a/Gemfile b/Gemfile index d8447a6..90f6e82 100644 --- a/Gemfile +++ b/Gemfile @@ -54,6 +54,7 @@ group :development, :test do gem 'byebug', platform: :mri gem 'pry-byebug' gem 'pry-rails' + gem 'table_print' gem 'faker' gem 'brakeman' diff --git a/Gemfile.lock b/Gemfile.lock index bbe87c3..a9e6a8f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -280,6 +280,7 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) + table_print (1.5.6) thor (0.19.4) thread_safe (0.3.5) tilt (2.0.5) @@ -348,6 +349,7 @@ DEPENDENCIES simplecov spring spring-watcher-listen (~> 2.0.0) + table_print turbolinks (~> 5) tzinfo-data uglifier (>= 1.3.0) diff --git a/app/controllers/admin/result_controller.rb b/app/controllers/admin/result_controller.rb index 48bb2b5..64e0fea 100644 --- a/app/controllers/admin/result_controller.rb +++ b/app/controllers/admin/result_controller.rb @@ -11,10 +11,10 @@ module Admin def index sort_case = "(case when review_status = 0 then '' else name end)" sort_with_case = sort_column == 'name' ? sort_case : sort_column - @candidates = Candidate.where(completed: true) - .includes(:recruiter) - .order("#{sort_with_case} #{sort_direction}") - .page(params[:page]) + @candidates = current_user.reviewees.where(completed: true) + .includes(:recruiter) + .order("#{sort_with_case} #{sort_direction}") + .page(params[:page]) end def view diff --git a/app/policies/quiz_policy.rb b/app/policies/quiz_policy.rb index 6f80113..f70114d 100644 --- a/app/policies/quiz_policy.rb +++ b/app/policies/quiz_policy.rb @@ -25,10 +25,10 @@ class QuizPolicy < ApplicationPolicy class Scope < Scope def resolve - if user.reviewer? - scope.joins(:reviewers).where('reviewer_to_quizzes.user_id = ?', user.id) - else + if user.acts_as_recruiter? scope + else + scope.joins(:reviewers).where('reviewer_to_quizzes.user_id = ?', user.id) end end end diff --git a/erd.pdf b/erd.pdf index 35d725d..306fb65 100644 Binary files a/erd.pdf and b/erd.pdf differ diff --git a/test/policies/quiz_policy_test.rb b/test/policies/quiz_policy_test.rb index e5eb7be..505f9f0 100644 --- a/test/policies/quiz_policy_test.rb +++ b/test/policies/quiz_policy_test.rb @@ -15,7 +15,7 @@ class QuizPolicyTest < PolicyAssertions::Test test 'should allow manager to scope' do scope = QuizPolicy::Scope.new(users(:manager), Quiz).resolve - assert_equal Quiz.count, scope.count + assert_equal users(:manager).quizzes.count, scope.count end test 'should allow reviewer to scope' do