54 lines
1.1 KiB
Ruby
54 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
require 'test_helper'
|
|
|
|
class ReviewerVoteTest < ActiveSupport::TestCase
|
|
test "the truth" do
|
|
assert ReviewerVote
|
|
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 = 6
|
|
|
|
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
|