rethinking question CRUD
This commit is contained in:
54
test/controllers/candidate_controller_test.rb
Normal file
54
test/controllers/candidate_controller_test.rb
Normal file
@ -0,0 +1,54 @@
|
||||
require 'test_helper'
|
||||
|
||||
class CandidateControllerTest < ActionDispatch::IntegrationTest
|
||||
def setup_auth candidate
|
||||
post validate_candidate_url, params: { test_id: candidate.test_hash }
|
||||
end
|
||||
|
||||
test "should get login" do
|
||||
get welcome_path
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should require auth or redirect" do
|
||||
get saved_path
|
||||
assert_redirected_to welcome_path
|
||||
|
||||
get thankyou_path
|
||||
assert_redirected_to welcome_path
|
||||
|
||||
get summary_path
|
||||
assert_redirected_to welcome_path
|
||||
|
||||
get question_path
|
||||
assert_redirected_to welcome_path
|
||||
|
||||
get question_path(questions(:fed1).id)
|
||||
assert_redirected_to welcome_path
|
||||
|
||||
get live_coder_path(questions(:fed1).id)
|
||||
assert_redirected_to welcome_path
|
||||
end
|
||||
|
||||
test "should auth to question" do
|
||||
setup_auth candidates(:martha)
|
||||
|
||||
assert_redirected_to question_path
|
||||
assert session[:test_id].present?
|
||||
end
|
||||
|
||||
test "should redirect to thankyou when completed" do
|
||||
setup_auth candidates(:richard)
|
||||
|
||||
assert_redirected_to thankyou_path
|
||||
end
|
||||
|
||||
test "should get summary if complete but not submitted" do
|
||||
setup_auth candidates(:dawn)
|
||||
|
||||
get summary_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
# should get flash message on bad question
|
||||
end
|
8
test/fixtures/answers.yml
vendored
8
test/fixtures/answers.yml
vendored
@ -39,7 +39,7 @@ dawn2:
|
||||
dawn3:
|
||||
candidate: dawn
|
||||
question: fed3
|
||||
answer: {html: "<h1>I'm a little tealpot</h1>", css: 'h1 {color: teal;}', js: ''}
|
||||
answer: {html: "dawn3 <h1>I'm a little tealpot</h1>", css: 'h1 {color: teal;}', js: ''}
|
||||
saved: 0
|
||||
submitted: true
|
||||
created_at: <%= DateTime.now() - 38.hours - 50.minutes %>
|
||||
@ -75,7 +75,7 @@ dawn6:
|
||||
dawn7:
|
||||
candidate: dawn
|
||||
question: fed7
|
||||
answer: {html: '<p>This means <strong>jQuery</strong> needs to be available in live-coder!</p>', css: "strong {font-size: 1.6em;}\n.green {color: green;}", js: '$("strong").addClass("green");'}
|
||||
answer: {html: 'dawn7 <p>This means <strong>jQuery</strong> needs to be available in live-coder!</p>', css: "strong {font-size: 1.6em;}\n.green {color: green;}", js: '$("strong").addClass("green");'}
|
||||
saved: 0
|
||||
submitted: true
|
||||
created_at: <%= DateTime.now() - 38.hours - 34.minutes %>
|
||||
@ -129,7 +129,7 @@ richard2:
|
||||
richard3:
|
||||
candidate: richard
|
||||
question: fed3
|
||||
answer: {html: '<h1>Salmon</h1>', css: 'h1 {color: salmon;}', js: ''}
|
||||
answer: {html: 'richard3 <h1>Salmon</h1>', css: 'h1 {color: salmon;}', js: ''}
|
||||
saved: 0
|
||||
submitted: true
|
||||
created_at: <%= DateTime.now() - 36.hours - 26.minutes %>
|
||||
@ -165,7 +165,7 @@ richard6:
|
||||
richard7:
|
||||
candidate: richard
|
||||
question: fed7
|
||||
answer: {html: '<p>This means <strong>jQuery</strong> needs to be available in live-coder!</p>', css: "strong {font-size: 1.6em;}\n.green {color: green;}", js: '$("strong").addClass("green");'}
|
||||
answer: {html: 'richard7 <p>This means <strong>jQuery</strong> needs to be available in live-coder!</p>', css: "strong {font-size: 1.6em;}\n.green {color: green;}", js: '$("strong").addClass("green");'}
|
||||
saved: 0
|
||||
submitted: true
|
||||
created_at: <%= DateTime.now() - 36.hours - 34.minutes %>
|
||||
|
4
test/fixtures/questions.yml
vendored
4
test/fixtures/questions.yml
vendored
@ -22,7 +22,7 @@ fed3:
|
||||
quiz: fed
|
||||
question: How would you create a widget that would fit in a 250px wide area as well as a 400px wide area?
|
||||
category: CSS
|
||||
input_type: live-coder
|
||||
input_type: live_code
|
||||
input_options:
|
||||
sort: 2
|
||||
active: true
|
||||
@ -58,7 +58,7 @@ fed7:
|
||||
quiz: fed
|
||||
question: Provide a code example to manipulate the DOM using jQuery/JavaScript to change the classname of a div 'classB' to 'classC', only if the div 'classA' exists in the page?
|
||||
category: Javascript
|
||||
input_type: live-coder
|
||||
input_type: live_code
|
||||
input_options:
|
||||
sort: 6
|
||||
active: true
|
||||
|
Reference in New Issue
Block a user