fixes #30 - edit from summary with out js
This commit is contained in:
parent
f4abe5e281
commit
330126d672
@ -26,14 +26,14 @@ class CandidateController < ApplicationController
|
||||
end
|
||||
|
||||
def question
|
||||
qid = prep_status.current_question_id
|
||||
qid = prep_status.current_question_id || params[:question_id]
|
||||
redirect_to :summary and return if qid.nil?
|
||||
prep_question qid
|
||||
prep_instance_answer @question
|
||||
end
|
||||
|
||||
def update_answer
|
||||
qid = params[:qid] ||= prep_status.current_question_id
|
||||
qid = answer_params[:question_id] || prep_status.current_question_id
|
||||
@answer = prep_answer qid
|
||||
send "process_#{prep_question(qid).input_type}"
|
||||
end
|
||||
@ -114,7 +114,7 @@ class CandidateController < ApplicationController
|
||||
render :question
|
||||
else
|
||||
# TODO: change params.key? to submit = save/next/summary
|
||||
redirect_to :summary and return if params.key?(:update)
|
||||
# redirect_to :summary and return if params.key?(:update)
|
||||
redirect_to :saved and return if params.key?(:save)
|
||||
redirect_to :question
|
||||
end
|
||||
|
@ -22,7 +22,7 @@
|
||||
<% if @status.on_summary %>
|
||||
|
||||
<div class="btn-container-summary">
|
||||
<input type="submit" name="update" value="Save and return to summary">
|
||||
<input type="submit" name="submit" value="Save and return to summary">
|
||||
</div>
|
||||
|
||||
<% else %>
|
||||
|
@ -6,7 +6,7 @@
|
||||
</p>
|
||||
|
||||
<% @quiz.each do |question| %>
|
||||
<%= form_for(:answer, url: post_answer_path(answer_id: question.answer_id, qid: question.question_id), html:{class: 'summary-form'}) do |form| %>
|
||||
<%= form_for(:answer, url: post_answer_path(answer_id: question.answer_id), html:{class: 'summary-form'}) do |form| %>
|
||||
<article class="answer-sec <%= question.input_type %>-type" data-qid="<%= question.question_id %>">
|
||||
<div class="question-heading">
|
||||
<div class="question-title">
|
||||
|
34
test/integration/question_flow_test.rb
Normal file
34
test/integration/question_flow_test.rb
Normal file
@ -0,0 +1,34 @@
|
||||
require 'test_helper'
|
||||
|
||||
class QuestionFlowTest < ActionDispatch::IntegrationTest
|
||||
def setup_auth candidate
|
||||
post validate_candidate_url, params: { test_id: candidate.test_hash }
|
||||
end
|
||||
|
||||
test "should load the first question" do
|
||||
setup_auth candidates(:martha)
|
||||
|
||||
get question_path
|
||||
assert_response :success
|
||||
assert_select '.question-text', questions(:fed1).question
|
||||
end
|
||||
|
||||
test "should load the summary" do
|
||||
setup_auth candidates(:dawn)
|
||||
|
||||
get summary_path
|
||||
assert_response :success
|
||||
assert_select '.prft-heading', 'Almost done!'
|
||||
end
|
||||
|
||||
test "can load specific question from summary" do
|
||||
setup_auth candidates(:dawn)
|
||||
question = questions(:fed4)
|
||||
|
||||
get question_path(question.id)
|
||||
assert_response :success
|
||||
assert_select '.question-text', question.question
|
||||
# TODO: add in capybara and test form post
|
||||
# assert_redirected summary_path
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user