diff --git a/Guardfile b/Guardfile index 7a847c9..1027353 100644 --- a/Guardfile +++ b/Guardfile @@ -75,7 +75,7 @@ guard :shell, all_on_start: true do # TODO: Annoyingly, all files are linted twice on start/full runs. Why? watch %r{app/assets/javascripts/*/.*} do |file| system %(echo "ESLint:\033[32m #{file[0]}\033[0m") - system %(eslint #{file[0]}) + system %(./node_modules/eslint/bin/eslint.js #{file[0]}) end end diff --git a/app/assets/images/thumb-down-red.png b/app/assets/images/thumb-down-red.png deleted file mode 100644 index 13c46e7..0000000 Binary files a/app/assets/images/thumb-down-red.png and /dev/null differ diff --git a/app/assets/images/thumb-down.png b/app/assets/images/thumb-down.png deleted file mode 100644 index 9cd2fb3..0000000 Binary files a/app/assets/images/thumb-down.png and /dev/null differ diff --git a/app/assets/images/thumb-up-green.png b/app/assets/images/thumb-up-green.png deleted file mode 100644 index 272a9b5..0000000 Binary files a/app/assets/images/thumb-up-green.png and /dev/null differ diff --git a/app/assets/images/thumb-up.png b/app/assets/images/thumb-up.png deleted file mode 100644 index 930eb04..0000000 Binary files a/app/assets/images/thumb-up.png and /dev/null differ diff --git a/app/models/user.rb b/app/models/user.rb index 7db5e31..a563182 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -6,6 +6,8 @@ class User < ApplicationRecord has_many :quizzes, through: :reviewer_to_quizzes has_many :votes, class_name: 'ReviewerVote' + has_many :reviewees, through: :quizzes, source: :candidates + validates :email, presence: true, uniqueness: true validates :name, presence: true validates :role, presence: true diff --git a/app/policies/reviewer_vote_policy.rb b/app/policies/reviewer_vote_policy.rb index 78de734..3455425 100644 --- a/app/policies/reviewer_vote_policy.rb +++ b/app/policies/reviewer_vote_policy.rb @@ -8,8 +8,7 @@ class ReviewerVotePolicy < ApplicationPolicy # Only Managers, and Admins, can veto a quiz result def up? - # return true if user.acts_as_admin? - # user.quizzes.include? record.candidate.quiz + # return true if user.reviewees.include? record.candidate true end diff --git a/app/views/admin/user/_form.html.erb b/app/views/admin/user/_form.html.erb index c3b5266..de44d21 100644 --- a/app/views/admin/user/_form.html.erb +++ b/app/views/admin/user/_form.html.erb @@ -15,12 +15,20 @@ <%= form.select :role, admin_role_options(user.role), include_blank: false %> - <%= form.collection_check_boxes(:quiz_ids, Quiz.all, :id, :name, {}, {class: 'checkbox'}) do | quiz | %> -
- <%= quiz.check_box( checked: user.quizzes.include?(quiz.object)) %> - <%= quiz.label %> -
- <% end %> +
+
Quiz Review List
+

+ Quizzes this user should be reviewing the results of.
+ Admins and Recruiters should not have any checked, unless they are expected + to participate in the technical review for that quiz. +

+ <%= form.collection_check_boxes(:quiz_ids, Quiz.all, :id, :name, {}, {class: 'checkbox'}) do | quiz | %> +
+ <%= quiz.check_box( checked: user.quizzes.include?(quiz.object)) %> + <%= quiz.label %> +
+ <% end %> +
<%= form.submit %> <% end %> diff --git a/erd.pdf b/erd.pdf index 2a66978..35d725d 100644 Binary files a/erd.pdf and b/erd.pdf differ diff --git a/test/controllers/admin/vote_controller_test.rb b/test/controllers/admin/vote_controller_test.rb index 093a9f2..f05e4e2 100644 --- a/test/controllers/admin/vote_controller_test.rb +++ b/test/controllers/admin/vote_controller_test.rb @@ -28,8 +28,10 @@ module Admin henry = candidates(:henry) get admin_up_vote_url(henry.test_hash) - assert_difference("Candidate.find(#{henry.id}).votes.nay.count", 1) do - get admin_down_vote_url(henry.test_hash) + assert_difference("Candidate.find(#{henry.id}).votes.yea.count", -1) do + assert_difference("Candidate.find(#{henry.id}).votes.nay.count", 1) do + get admin_down_vote_url(henry.test_hash) + end end assert_response :success end diff --git a/test/fixtures/reviewer_to_quizzes.yml b/test/fixtures/reviewer_to_quizzes.yml index 4e8812f..cb91027 100644 --- a/test/fixtures/reviewer_to_quizzes.yml +++ b/test/fixtures/reviewer_to_quizzes.yml @@ -7,3 +7,7 @@ one: two: user: reviewer2 quiz: fed + +three: + user: manager + quiz: fed diff --git a/test/policies/reviewer_vote_policy_test.rb b/test/policies/reviewer_vote_policy_test.rb index 8dc05a8..5447738 100644 --- a/test/policies/reviewer_vote_policy_test.rb +++ b/test/policies/reviewer_vote_policy_test.rb @@ -29,14 +29,13 @@ class ReviewerVotePolicyTest < PolicyAssertions::Test end def test_up - skip - # assert_permit users(:admin), candidates(:richard) + # refute_permit users(:admin), reviewer_votes(:manager_henry) + # refute_permit users(:recruiter), candidates(:richard) + # refute_permit users(:reviewer), candidates(:gustov) + # assert_permit users(:admin), candidates(:gustov) # assert_permit users(:manager), candidates(:richard) # assert_permit users(:reviewer), candidates(:richard) - # - # refute_permit users(:reviewer), candidates(:gustov) - # refute_permit users(:recruiter), candidates(:richard) end # def test_create_and_update