# frozen_string_literal: true require 'test_helper' module Admin class VoteControllerTest < ActionDispatch::IntegrationTest test "reviewer can up vote henry" do auth_user users(:reviewer) henry = candidates(:henry) assert_difference("Candidate.find(#{henry.id}).votes.yea.count", 1) do get admin_up_vote_url(henry.test_hash) end assert_response :success end test "reviewer can down vote henry" do auth_user users(:reviewer) henry = candidates(:henry) assert_difference("Candidate.find(#{henry.id}).votes.nay.count", 1) do get admin_down_vote_url(henry.test_hash) end assert_response :success end test "reviewer can change vote on henry" do auth_user users(:reviewer) henry = candidates(:henry) get admin_up_vote_url(henry.test_hash) assert_difference("Candidate.find(#{henry.id}).votes.nay.count", 1) do get admin_down_vote_url(henry.test_hash) end assert_response :success end test "manager can approve henry" do auth_user users(:manager) henry = candidates(:henry) get admin_approve_vote_url(henry.test_hash) assert_equal 1, henry.votes.approved.count assert_equal 'approved', Candidate.find(henry.to_i).review_status assert_response :success end test "manager can decline henry" do auth_user users(:manager) henry = candidates(:henry) get admin_decline_vote_url(henry.test_hash) assert_equal 1, henry.votes.rejected.count assert_equal 'declined', Candidate.find(henry.to_i).review_status assert_response :success end end end