diff --git a/app/models/reviewer_vote.rb b/app/models/reviewer_vote.rb new file mode 100644 index 0000000..8f52019 --- /dev/null +++ b/app/models/reviewer_vote.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 35ed228..9d601e3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/db/migrate/20161118023249_candidate_review_system.rb b/db/migrate/20161118023249_candidate_review_system.rb new file mode 100644 index 0000000..0c4c8b0 --- /dev/null +++ b/db/migrate/20161118023249_candidate_review_system.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 41a294d..caafb90 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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" diff --git a/erd.pdf b/erd.pdf index 1d050f2..d662d8d 100644 Binary files a/erd.pdf and b/erd.pdf differ diff --git a/test/fixtures/answers.yml b/test/fixtures/answers.yml index 9c3455a..feda3fa 100644 --- a/test/fixtures/answers.yml +++ b/test/fixtures/answers.yml @@ -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: '
This means jQuery needs to be available in live-coder!
', 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: 'This means jQuery needs to be available in live-coder!
', 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: 'This means jQuery needs to be available in live-coder!
', 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 %> + diff --git a/test/fixtures/candidates.yml b/test/fixtures/candidates.yml index a3c07f7..237c23a 100644 --- a/test/fixtures/candidates.yml +++ b/test/fixtures/candidates.yml @@ -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 + diff --git a/test/fixtures/reviewer_votes.yml b/test/fixtures/reviewer_votes.yml new file mode 100644 index 0000000..06a1b3c --- /dev/null +++ b/test/fixtures/reviewer_votes.yml @@ -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 + diff --git a/test/models/reviewer_vote_test.rb b/test/models/reviewer_vote_test.rb new file mode 100644 index 0000000..1ce2161 --- /dev/null +++ b/test/models/reviewer_vote_test.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true +require 'test_helper' + +class ReviewerVoteTest < ActiveSupport::TestCase + test "the truth" do + assert ReviewerVoteTest + end +end