This commit is contained in:
Mark Moser 2016-11-17 22:43:19 -06:00
parent 85674b40a6
commit 37aa17ec1f
9 changed files with 451 additions and 3 deletions

View File

@ -0,0 +1,18 @@
# frozen_string_literal: true
class ReviewerVote < ApplicationRecord
# validates :user_id, uniqueness: {scope: :friend_id}
belongs_to :candidate
belongs_to :user
enum vote: {
undecided: 0,
yea: 1,
nay: 2
}
enum veto: {
approved: 1,
rejected: 2
}
end

View File

@ -4,6 +4,7 @@ class User < ApplicationRecord
has_many :candidates, foreign_key: :recruiter_id
has_many :reviewer_to_quizzes
has_many :quizzes, through: :reviewer_to_quizzes
has_many :votes, class_name: 'ReviewerVote'
validates :email, presence: true, uniqueness: true
validates :name, presence: true

View File

@ -0,0 +1,18 @@
# frozen_string_literal: true
class CandidateReviewSystem < ActiveRecord::Migration[5.0]
def change
create_table :reviewer_votes do |t|
t.integer :candidate_id
t.integer :user_id
t.integer :vote, default: 0, null: false
t.integer :veto, default: 0, null: false
t.datetime :last_reminded
t.boolean :locked, default: false, null: false
t.timestamps
end
add_index :reviewer_votes, [:candidate_id, :user_id], unique: true
add_column :candidates, :review_status, :integer, default: 0, null: false
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160915164450) do
ActiveRecord::Schema.define(version: 20161118023249) do
create_table "answers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.integer "candidate_id"
@ -33,9 +33,10 @@ ActiveRecord::Schema.define(version: 20160915164450) do
t.integer "recruiter_id"
t.boolean "completed"
t.boolean "reminded"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "quiz_id"
t.integer "review_status", default: 0, null: false
t.index ["quiz_id"], name: "index_candidates_on_quiz_id", using: :btree
t.index ["recruiter_id"], name: "index_candidates_on_recruiter_id", using: :btree
t.index ["test_hash"], name: "index_candidates_on_test_hash", unique: true, using: :btree
@ -73,6 +74,18 @@ ActiveRecord::Schema.define(version: 20160915164450) do
t.index ["quiz_id"], name: "index_reviewer_to_quizzes_on_quiz_id", using: :btree
end
create_table "reviewer_votes", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.integer "candidate_id"
t.integer "user_id"
t.integer "vote", default: 0, null: false
t.integer "veto", default: 0, null: false
t.datetime "last_reminded"
t.boolean "locked", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["candidate_id", "user_id"], name: "index_reviewer_votes_on_candidate_id_and_user_id", unique: true, using: :btree
end
create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "name"
t.string "email"

BIN
erd.pdf

Binary file not shown.

View File

@ -404,3 +404,295 @@ juan10:
created_at: <%= DateTime.now() - 38.hours - 40.minutes %>
updated_at: <%= DateTime.now() - 38.hours - 20.minutes %>
stacy1:
candidate: stacy
question: Cras justo odio, dapibus ac facilisis in, egestas eget quam. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit.
answer: option 3
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 22.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 22.minutes %>
stacy2:
candidate: stacy
question: fed2
answer: 'indexOf()'
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 24.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 4.minutes %>
stacy3:
candidate: stacy
question: fed3
answer: {html: '<h1>Salmon</h1>', css: 'h1 {color: salmon;}', js: '', text: 'Gotta lotta GOOD things on sale, strangah.'}
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 26.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 6.minutes %>
stacy4:
candidate: stacy
question: fed4
answer: Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 28.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 28.minutes %>
stacy5:
candidate: stacy
question: fed5
answer: 'Dynamic listeners'
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 30.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 30.minutes %>
stacy6:
candidate: stacy
question: fed6
answer: Integer posuere erat a ante venenatis dapibus posuere velit aliquet.
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 32.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 12.minutes %>
stacy7:
candidate: stacy
question: fed7
answer: {html: '<p>This means <strong>jQuery</strong> needs to be available in live-coder!</p>', css: "strong {font-size: 1.6em;}\n.green {color: green;}", js: '$("strong").addClass("green");'}
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 34.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 14.minutes %>
stacy8:
candidate: stacy
question: fed8
answer:
other: Some generic user input
options:
- other
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 36.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 16.minutes %>
stacy9:
candidate: stacy
question: fed9
answer:
other: Brunch
options:
- Neither
- other
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 38.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 18.minutes %>
stacy10:
candidate: stacy
question: fed10
answer: ["Live long and prosper", "Who you calling Scruffy?"]
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 40.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 20.minutes %>
henry1:
candidate: henry
question: Cras justo odio, dapibus ac facilisis in, egestas eget quam. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit.
answer: option 3
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 22.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 22.minutes %>
henry2:
candidate: henry
question: fed2
answer: 'indexOf()'
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 24.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 4.minutes %>
henry3:
candidate: henry
question: fed3
answer: {html: '<h1>Salmon</h1>', css: 'h1 {color: salmon;}', js: '', text: 'Gotta lotta GOOD things on sale, strangah.'}
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 26.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 6.minutes %>
henry4:
candidate: henry
question: fed4
answer: Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 28.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 28.minutes %>
henry5:
candidate: henry
question: fed5
answer: 'Dynamic listeners'
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 30.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 30.minutes %>
henry6:
candidate: henry
question: fed6
answer: Integer posuere erat a ante venenatis dapibus posuere velit aliquet.
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 32.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 12.minutes %>
henry7:
candidate: henry
question: fed7
answer: {html: '<p>This means <strong>jQuery</strong> needs to be available in live-coder!</p>', css: "strong {font-size: 1.6em;}\n.green {color: green;}", js: '$("strong").addClass("green");'}
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 34.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 14.minutes %>
henry8:
candidate: henry
question: fed8
answer:
other: Some generic user input
options:
- other
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 36.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 16.minutes %>
henry9:
candidate: henry
question: fed9
answer:
other: Brunch
options:
- Neither
- other
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 38.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 18.minutes %>
henry10:
candidate: henry
question: fed10
answer: ["Live long and prosper", "Who you calling Scruffy?"]
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 40.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 20.minutes %>
martin1:
candidate: martin
question: Cras justo odio, dapibus ac facilisis in, egestas eget quam. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit.
answer: option 3
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 22.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 22.minutes %>
martin2:
candidate: martin
question: fed2
answer: 'indexOf()'
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 24.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 4.minutes %>
martin3:
candidate: martin
question: fed3
answer: {html: '<h1>Salmon</h1>', css: 'h1 {color: salmon;}', js: '', text: 'Gotta lotta GOOD things on sale, strangah.'}
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 26.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 6.minutes %>
martin4:
candidate: martin
question: fed4
answer: Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 28.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 28.minutes %>
martin5:
candidate: martin
question: fed5
answer: 'Dynamic listeners'
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 30.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 30.minutes %>
martin6:
candidate: martin
question: fed6
answer: Integer posuere erat a ante venenatis dapibus posuere velit aliquet.
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 32.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 12.minutes %>
martin7:
candidate: martin
question: fed7
answer: {html: '<p>This means <strong>jQuery</strong> needs to be available in live-coder!</p>', css: "strong {font-size: 1.6em;}\n.green {color: green;}", js: '$("strong").addClass("green");'}
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 34.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 14.minutes %>
martin8:
candidate: martin
question: fed8
answer:
other: Some generic user input
options:
- other
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 36.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 16.minutes %>
martin9:
candidate: martin
question: fed9
answer:
other: Brunch
options:
- Neither
- other
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 38.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 18.minutes %>
martin10:
candidate: martin
question: fed10
answer: ["Live long and prosper", "Who you calling Scruffy?"]
saved: 0
submitted: true
created_at: <%= DateTime.now() - 36.hours - 40.minutes %>
updated_at: <%= DateTime.now() - 36.hours - 20.minutes %>

View File

@ -69,3 +69,34 @@ juan: # Juan has chosen "finish later" for live coders
completed: false
reminded: true
test_hash: qKQo0l4dyol
stacy: # Stacy has completed AND submitted the test
name: Stacy Scott
email: <%= CryptSerializer.dump 'stacy.scott@mailinator.com' %>
experience: 7-9
recruiter: recruiter
quiz: fed
completed: true
reminded: false
test_hash: s6oFExZliYYFx
henry: # Henry has completed AND submitted the test
name: Henry Butler
email: <%= CryptSerializer.dump 'henry.butler@mailinator.com' %>
experience: 4-6
recruiter: recruiter
quiz: fed
completed: true
reminded: false
test_hash: egPomAuVDeCEp
wade: # Wade has completed AND submitted the test
name: Wade Armstrong
email: <%= CryptSerializer.dump 'wade.armstrong@mailinator.com' %>
experience: 0-3
recruiter: recruiter
quiz: fed
completed: true
reminded: false
test_hash: BkSkpa/pJnkz2N

67
test/fixtures/reviewer_votes.yml vendored Normal file
View File

@ -0,0 +1,67 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
manager_richard:
candidate: richard
user: manager
vote: 1
reviewer_richard:
candidate: richard
user: reviewer
vote: 1
reviewer2_richard:
candidate: richard
user: reviewer2
vote: 1
manager_wade:
candidate: wade
user: manager
vote: 2
veto: 2
reviewer_wade:
candidate: wade
user: reviewer
vote: 2
# reviewer2_wade:
# candidate: wade
# user: reviewer2
manager_stacy:
candidate: stacy
user: manager
vote: 2
reviewer_stacy:
candidate: stacy
user: reviewer
vote: 2
reviewer2_stacy:
candidate: stacy
user: reviewer2
vote: 2
manager_henry:
candidate: henry
user: manager
vote: 0
veto: 2
# reviewer_henry:
# candidate: henry
# user: reviewer
#
# reviewer2_henry:
# candidate: henry
# user: reviewer2

View File

@ -0,0 +1,8 @@
# frozen_string_literal: true
require 'test_helper'
class ReviewerVoteTest < ActiveSupport::TestCase
test "the truth" do
assert ReviewerVoteTest
end
end