fixed up a reviewer to reviewee association

This commit is contained in:
Mark Moser 2016-11-20 09:51:46 -06:00
parent e0f5e482be
commit 5ef7f82dbf
12 changed files with 30 additions and 16 deletions

View File

@ -75,7 +75,7 @@ guard :shell, all_on_start: true do
# TODO: Annoyingly, all files are linted twice on start/full runs. Why? # TODO: Annoyingly, all files are linted twice on start/full runs. Why?
watch %r{app/assets/javascripts/*/.*} do |file| watch %r{app/assets/javascripts/*/.*} do |file|
system %(echo "ESLint:\033[32m #{file[0]}\033[0m") system %(echo "ESLint:\033[32m #{file[0]}\033[0m")
system %(eslint #{file[0]}) system %(./node_modules/eslint/bin/eslint.js #{file[0]})
end end
end end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 B

View File

@ -6,6 +6,8 @@ class User < ApplicationRecord
has_many :quizzes, through: :reviewer_to_quizzes has_many :quizzes, through: :reviewer_to_quizzes
has_many :votes, class_name: 'ReviewerVote' has_many :votes, class_name: 'ReviewerVote'
has_many :reviewees, through: :quizzes, source: :candidates
validates :email, presence: true, uniqueness: true validates :email, presence: true, uniqueness: true
validates :name, presence: true validates :name, presence: true
validates :role, presence: true validates :role, presence: true

View File

@ -8,8 +8,7 @@ class ReviewerVotePolicy < ApplicationPolicy
# Only Managers, and Admins, can veto a quiz result # Only Managers, and Admins, can veto a quiz result
def up? def up?
# return true if user.acts_as_admin? # return true if user.reviewees.include? record.candidate
# user.quizzes.include? record.candidate.quiz
true true
end end

View File

@ -15,12 +15,20 @@
<%= form.select :role, admin_role_options(user.role), include_blank: false %> <%= form.select :role, admin_role_options(user.role), include_blank: false %>
</div> </div>
<div class="form-group">
<div><strong>Quiz Review List</strong></div>
<p>
Quizzes this user should be reviewing the results of.<br />
Admins and Recruiters should not have any checked, unless they are expected
to participate in the technical review for that quiz.
</p>
<%= form.collection_check_boxes(:quiz_ids, Quiz.all, :id, :name, {}, {class: 'checkbox'}) do | quiz | %> <%= form.collection_check_boxes(:quiz_ids, Quiz.all, :id, :name, {}, {class: 'checkbox'}) do | quiz | %>
<div class="form-group-multiples"> <div class="form-group-multiples">
<%= quiz.check_box( checked: user.quizzes.include?(quiz.object)) %> <%= quiz.check_box( checked: user.quizzes.include?(quiz.object)) %>
<%= quiz.label %> <%= quiz.label %>
</div> </div>
<% end %> <% end %>
</div>
<%= form.submit %> <%= form.submit %>
<% end %> <% end %>

BIN
erd.pdf

Binary file not shown.

View File

@ -28,9 +28,11 @@ module Admin
henry = candidates(:henry) henry = candidates(:henry)
get admin_up_vote_url(henry.test_hash) get admin_up_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 assert_difference("Candidate.find(#{henry.id}).votes.nay.count", 1) do
get admin_down_vote_url(henry.test_hash) get admin_down_vote_url(henry.test_hash)
end end
end
assert_response :success assert_response :success
end end

View File

@ -7,3 +7,7 @@ one:
two: two:
user: reviewer2 user: reviewer2
quiz: fed quiz: fed
three:
user: manager
quiz: fed

View File

@ -29,14 +29,13 @@ class ReviewerVotePolicyTest < PolicyAssertions::Test
end end
def test_up def test_up
skip # refute_permit users(:admin), reviewer_votes(:manager_henry)
# assert_permit users(:admin), candidates(:richard) # refute_permit users(:recruiter), candidates(:richard)
# refute_permit users(:reviewer), candidates(:gustov)
# assert_permit users(:admin), candidates(:gustov) # assert_permit users(:admin), candidates(:gustov)
# assert_permit users(:manager), candidates(:richard) # assert_permit users(:manager), candidates(:richard)
# assert_permit users(:reviewer), candidates(:richard) # assert_permit users(:reviewer), candidates(:richard)
#
# refute_permit users(:reviewer), candidates(:gustov)
# refute_permit users(:recruiter), candidates(:richard)
end end
# def test_create_and_update # def test_create_and_update