skill-assessment-app/test/models/reviewer_vote_test.rb
2017-02-09 16:26:33 -06:00

54 lines
1.2 KiB
Ruby

# frozen_string_literal: true
require 'test_helper'
class ReviewerVoteTest < ActiveSupport::TestCase
test "the truth" do
assert ReviewerVoteTest
end
test "richard has 3 votes" do
richard = candidates(:richard)
assert_equal 3, richard.votes.size
end
test "manager has a vote for every completed quiz" do
manager = users(:manager)
completed_count = Candidate.where(completed: true).count
assert_equal completed_count, manager.votes.size
end
test "richard has been approved" do
richard = candidates(:richard)
assert richard.approved?
refute richard.declined?
end
test "stacy has been declined" do
stacy = candidates(:stacy)
assert stacy.declined?
refute stacy.approved?
end
test "mailer is queued on last vote" do
reviewer = users(:reviewer2)
candidate = candidates(:jorge)
assert_difference("ActionMailer::Base.deliveries.size", 1) do
reviewer.cast_yea_on(candidate)
end
end
test "mailer is NOT queued on first vote" do
reviewer = users(:reviewer2)
candidate = candidates(:elsie)
assert_difference("ActionMailer::Base.deliveries.size", 0) do
reviewer.cast_yea_on(candidate)
end
end
end