skill-assessment-app/test/models/reviewer_vote_test.rb

54 lines
1.2 KiB
Ruby
Raw Normal View History

2016-11-17 22:43:19 -06:00
# frozen_string_literal: true
require 'test_helper'
class ReviewerVoteTest < ActiveSupport::TestCase
test "the truth" do
2017-02-10 12:03:50 -06:00
assert ReviewerVote
2016-11-17 22:43:19 -06:00
end
2016-11-18 17:43:24 -06:00
test "richard has 3 votes" do
richard = candidates(:richard)
assert_equal 3, richard.votes.size
end
2017-02-09 16:26:33 -06:00
test "manager has a vote for every completed quiz" do
2016-11-18 17:43:24 -06:00
manager = users(:manager)
2017-02-09 16:26:33 -06:00
completed_count = Candidate.where(completed: true).count
2016-11-18 17:43:24 -06:00
2017-02-09 16:26:33 -06:00
assert_equal completed_count, manager.votes.size
2016-11-18 17:43:24 -06:00
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
2017-02-09 16:26:33 -06:00
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
2016-11-17 22:43:19 -06:00
end