bug fix #105
This commit is contained in:
commit
0e17ff09c2
@ -61,7 +61,7 @@ module Admin
|
|||||||
end
|
end
|
||||||
|
|
||||||
def collect_quizzes
|
def collect_quizzes
|
||||||
@quizzes ||= Quiz.order(:name)
|
@quizzes ||= Quiz.all_active.order(:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_notifications candidate
|
def send_notifications candidate
|
||||||
|
@ -8,4 +8,10 @@ class Quiz < ApplicationRecord
|
|||||||
validates :name, presence: true, uniqueness: true
|
validates :name, presence: true, uniqueness: true
|
||||||
validates :dept, presence: true
|
validates :dept, presence: true
|
||||||
validates :unit, presence: true
|
validates :unit, presence: true
|
||||||
|
|
||||||
|
class << self
|
||||||
|
def all_active
|
||||||
|
Quiz.joins(:questions).distinct
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
5
test/fixtures/quizzes.yml
vendored
5
test/fixtures/quizzes.yml
vendored
@ -14,3 +14,8 @@ studio:
|
|||||||
name: Studio Screening One
|
name: Studio Screening One
|
||||||
unit: PD Studio
|
unit: PD Studio
|
||||||
dept: FED
|
dept: FED
|
||||||
|
|
||||||
|
empty_quiz:
|
||||||
|
name: A quiz with no questions
|
||||||
|
unit: PD
|
||||||
|
dept: FED
|
||||||
|
@ -2,7 +2,10 @@
|
|||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class QuizTest < ActiveSupport::TestCase
|
class QuizTest < ActiveSupport::TestCase
|
||||||
# test "the truth" do
|
test "all_active only returns quizzes with questions" do
|
||||||
# assert true
|
empty_quiz = quizzes(:empty_quiz)
|
||||||
# end
|
quizzes = Quiz.all_active
|
||||||
|
|
||||||
|
refute quizzes.any? { |q| q.id == empty_quiz.id }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user