limit candidate quiz dropdown to only show "active" quizzes
completes #105
This commit is contained in:
parent
e6cc00ca57
commit
15a5b6b706
@ -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
|
||||
|
@ -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
|
||||
|
5
test/fixtures/quizzes.yml
vendored
5
test/fixtures/quizzes.yml
vendored
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user