init comments
This commit is contained in:
parent
37f6e49592
commit
9c2b53aa79
@ -6,6 +6,7 @@ class Candidate < ApplicationRecord
|
||||
belongs_to :recruiter, class_name: "User"
|
||||
has_many :votes, class_name: "ReviewerVote"
|
||||
has_many :reviewers, through: :quiz
|
||||
has_many :quiz_comments, foreign_key: :test_hash, primary_key: :test_hash
|
||||
|
||||
serialize :email, CryptSerializer
|
||||
|
||||
|
7
app/models/quiz_comment.rb
Normal file
7
app/models/quiz_comment.rb
Normal file
@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
class QuizComment < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :candidate, foreign_key: :test_hash, primary_key: :test_hash
|
||||
|
||||
validates :message, presence: true
|
||||
end
|
@ -5,6 +5,7 @@ class User < ApplicationRecord
|
||||
has_many :reviewer_to_quizzes
|
||||
has_many :quizzes, through: :reviewer_to_quizzes
|
||||
has_many :votes, class_name: 'ReviewerVote'
|
||||
has_many :quiz_comments
|
||||
|
||||
has_many :reviewees, through: :quizzes, source: :candidates
|
||||
|
||||
|
12
db/migrate/20170210165110_create_quiz_comments.rb
Normal file
12
db/migrate/20170210165110_create_quiz_comments.rb
Normal file
@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
class CreateQuizComments < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :quiz_comments do |t|
|
||||
t.integer :user_id
|
||||
t.string :test_hash
|
||||
t.text :message
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
10
db/schema.rb
10
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: 20170208212526) do
|
||||
ActiveRecord::Schema.define(version: 20170210165110) do
|
||||
|
||||
create_table "answers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
|
||||
t.integer "candidate_id"
|
||||
@ -60,6 +60,14 @@ ActiveRecord::Schema.define(version: 20170208212526) do
|
||||
t.index ["sort"], name: "index_questions_on_sort", using: :btree
|
||||
end
|
||||
|
||||
create_table "quiz_comments", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
|
||||
t.integer "user_id"
|
||||
t.string "test_hash"
|
||||
t.text "message", limit: 65535
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "quizzes", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
|
||||
t.string "unit"
|
||||
t.string "dept"
|
||||
|
72
test/fixtures/quiz_comments.yml
vendored
Normal file
72
test/fixtures/quiz_comments.yml
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
com1:
|
||||
test_hash: BkSkpapJnkz2N #wade
|
||||
user: reviewer
|
||||
message: Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Etiam porta sem malesuada magna mollis euismod. Aenean lacinia bibendum nulla sed consectetur. Maecenas faucibus mollis interdum.
|
||||
|
||||
com2:
|
||||
test_hash: BkSkpapJnkz2N #wade
|
||||
user: reviewer
|
||||
message: Donec sed odio dui. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Curabitur blandit tempus porttitor. Nullam quis risus eget urna mollis ornare vel eu leo. Nullam id dolor id nibh ultricies vehicula ut id elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
|
||||
com3:
|
||||
test_hash: BkSkpapJnkz2N #wade
|
||||
user: reviewer2
|
||||
message: Cras mattis consectetur purus sit amet fermentum. Donec sed odio dui. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
|
||||
|
||||
com4:
|
||||
test_hash: iC5FdWJxcyySBmpOpU #jorge
|
||||
user: manager
|
||||
message: Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed posuere consectetur est at lobortis.
|
||||
|
||||
com5:
|
||||
test_hash: egPomAuVDeCEp #henry
|
||||
user: manager
|
||||
message: no.
|
||||
|
||||
com6:
|
||||
test_hash: egPomAuVDeCEp #henry
|
||||
user: reviewer2
|
||||
message: fine.
|
||||
|
||||
com7:
|
||||
test_hash: iC5FdWJxcyySBmpOpU #jorge
|
||||
user: reviewer
|
||||
message: Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.
|
||||
|
||||
com8:
|
||||
test_hash: egPomAuVDeCEp #henry
|
||||
user: manager
|
||||
message: no.
|
||||
|
||||
com9:
|
||||
test_hash: rLSoizA3ATMNSCx #elsie
|
||||
user: reviewer
|
||||
message: Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Etiam porta sem malesuada magna mollis euismod. Vestibulum id ligula porta felis euismod semper. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Maecenas faucibus mollis interdum.
|
||||
|
||||
com10:
|
||||
test_hash: rLSoizA3ATMNSCx #elsie
|
||||
user: reviewer2
|
||||
message: Ornare Tellus Nullam Mattis
|
||||
|
||||
com11:
|
||||
test_hash: rLSoizA3ATMNSCx #elsie
|
||||
user: reviewer2
|
||||
message: Nibh Ultricies Purus
|
||||
|
||||
com12:
|
||||
test_hash: rLSoizA3ATMNSCx #elsie
|
||||
user: reviewer
|
||||
message: Donec id elit non mi porta gravida at eget metus.
|
||||
|
||||
com13:
|
||||
test_hash: rLSoizA3ATMNSCx #elsie
|
||||
user: manager
|
||||
message: Donec id elit non mi porta gravida at eget metus.
|
||||
|
||||
com14:
|
||||
test_hash: rLSoizA3ATMNSCx #elsie
|
||||
user: reviewer2
|
||||
message: Ultricies Vulputate Bibendum Parturient
|
||||
|
27
test/models/quiz_comment_test.rb
Normal file
27
test/models/quiz_comment_test.rb
Normal file
@ -0,0 +1,27 @@
|
||||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
class QuizCommentTest < ActiveSupport::TestCase
|
||||
test "the truth" do
|
||||
assert QuizComment
|
||||
end
|
||||
|
||||
test "user to comments association" do
|
||||
manager = users(:manager)
|
||||
|
||||
assert_equal 4, manager.quiz_comments.size
|
||||
end
|
||||
|
||||
test "candidate to comments association" do
|
||||
candidate = candidates(:elsie)
|
||||
|
||||
assert_equal 6, candidate.quiz_comments.size
|
||||
end
|
||||
|
||||
test 'comment to user' do
|
||||
comment = quiz_comments(:com1)
|
||||
|
||||
assert_match 'Wade', comment.candidate.name
|
||||
assert_match 'Tina', comment.user.name
|
||||
end
|
||||
end
|
@ -3,7 +3,7 @@ require 'test_helper'
|
||||
|
||||
class ReviewerVoteTest < ActiveSupport::TestCase
|
||||
test "the truth" do
|
||||
assert ReviewerVoteTest
|
||||
assert ReviewerVote
|
||||
end
|
||||
|
||||
test "richard has 3 votes" do
|
||||
|
Loading…
Reference in New Issue
Block a user