This commit is contained in:
Mark Moser 2017-06-05 11:30:58 -05:00
commit 0e17ff09c2
4 changed files with 18 additions and 4 deletions

View File

@ -61,7 +61,7 @@ module Admin
end
def collect_quizzes
@quizzes ||= Quiz.order(:name)
@quizzes ||= Quiz.all_active.order(:name)
end
def send_notifications candidate

View File

@ -8,4 +8,10 @@ class Quiz < ApplicationRecord
validates :name, presence: true, uniqueness: true
validates :dept, presence: true
validates :unit, presence: true
class << self
def all_active
Quiz.joins(:questions).distinct
end
end
end

View File

@ -14,3 +14,8 @@ studio:
name: Studio Screening One
unit: PD Studio
dept: FED
empty_quiz:
name: A quiz with no questions
unit: PD
dept: FED

View File

@ -2,7 +2,10 @@
require 'test_helper'
class QuizTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test "all_active only returns quizzes with questions" do
empty_quiz = quizzes(:empty_quiz)
quizzes = Quiz.all_active
refute quizzes.any? { |q| q.id == empty_quiz.id }
end
end