diff --git a/app/models/candidate.rb b/app/models/candidate.rb index e2f171e..7da2524 100644 --- a/app/models/candidate.rb +++ b/app/models/candidate.rb @@ -18,6 +18,7 @@ class Candidate < ApplicationRecord def answered_questions answers.where.not(answer: nil) + .where("answers.answer not like '%later:%'") end def fetch_question qid @@ -25,12 +26,15 @@ class Candidate < ApplicationRecord end def my_quiz - CandidateQuiz.new(id).build_my_quiz + @candidate_quiz ||= CandidateQuiz.new(id).build_my_quiz + end + + def my_status + @candidate_status ||= QuizStatus.new(self) end def status - # TODO: quiz status: not started, started, completed - "--" + "#{my_status.progress}%" end def complete! diff --git a/app/views/recruiter/index.html.erb b/app/views/recruiter/index.html.erb index 5acc288..128756d 100644 --- a/app/views/recruiter/index.html.erb +++ b/app/views/recruiter/index.html.erb @@ -11,7 +11,9 @@ Test ID Email Experience - Status + Progress + Completed + Reminded <% @candidates.each do |candidate| %> @@ -21,6 +23,8 @@ <%= mail_to(candidate.email) %> <%= candidate.experience %> years <%= candidate.status %> + <%= candidate.completed ? "Submitted" : "" %> + <%= candidate.reminded ? "Yes" : "" %> <% end %> diff --git a/test/fixtures/answers.yml b/test/fixtures/answers.yml index e71e2de..c7f03a7 100644 --- a/test/fixtures/answers.yml +++ b/test/fixtures/answers.yml @@ -373,8 +373,9 @@ juan9: juan10: candidate: juan question: fed10 - answer: + answer: 'wibbly wobbly, timey wimey' saved: 1 submitted: true created_at: <%= DateTime.now() - 38.hours - 40.minutes %> updated_at: <%= DateTime.now() - 38.hours - 20.minutes %> + diff --git a/test/integration/question_flow_test.rb b/test/integration/question_flow_test.rb index 048ea0b..ee79aa8 100644 --- a/test/integration/question_flow_test.rb +++ b/test/integration/question_flow_test.rb @@ -31,4 +31,12 @@ class QuestionFlowTest < ActionDispatch::IntegrationTest # TODO: add in capybara and test form post # assert_redirected summary_path end + + test 'juan should be on summary with 80% complete' do + setup_auth candidates(:juan) + + get summary_path + assert_response :success + assert_select '.progress span', '80%' + end end