# frozen_string_literal: true
require 'test_helper'

class CandidateReminderTest < ActiveSupport::TestCase
  test "collection is created with one result" do
    reminders = CandidateReminder.new
    assert_equal 1, reminders.size
  end

  test "each candidate has needed attributes" do
    reminders = CandidateReminder.new

    assert_instance_of String, reminders.candidates.first.name
    assert_instance_of String, reminders.candidates.first.test_hash
    assert_instance_of String, reminders.candidates.first.email
  end

  test "send reminders sends email, and flags reminded" do
    reminders = CandidateReminder.new
    pre_reminded = Candidate.find(reminders.candidates.first.id).reminded

    assert_difference("ActionMailer::Base.deliveries.size", reminders.count) do
      reminders.send_all
    end
    refute_equal pre_reminded, Candidate.find(reminders.candidates.first.id).reminded
  end
end
