testing existance of instance var for views

This commit is contained in:
Mark Moser 2016-08-17 13:58:25 -05:00
parent 14bbd301ed
commit 86c36fd7fb
7 changed files with 47 additions and 6 deletions

View File

@ -39,6 +39,7 @@ group :development, :test do
gem 'minitest-reporters'
gem 'pry-byebug'
gem 'pry-rails'
gem 'rails-controller-testing'
gem 'rubocop', '~> 0.42.0'
gem 'simplecov', require: false
gem 'spring'

View File

@ -178,6 +178,10 @@ GEM
bundler (>= 1.3.0, < 2.0)
railties (= 5.0.0)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.1)
actionpack (~> 5.x)
actionview (~> 5.x)
activesupport (~> 5.x)
rails-dom-testing (2.0.1)
activesupport (>= 4.2.0, < 6.0)
nokogiri (~> 1.6.0)
@ -290,6 +294,7 @@ DEPENDENCIES
puma (~> 3.0)
rack-livereload
rails (~> 5.0.0)
rails-controller-testing
rails-erd
rubocop (~> 0.42.0)
sass-rails (~> 5.0)

View File

@ -1,5 +0,0 @@
<footer>
<div class="footer_title"><h2><%= yield(:footer_title) %></h2></div>
<div class="pd_logo"><%= image_tag("perficientdigital.png", alt:"Perficient Digital") %></div>
<div class="footer_yellow-bar slantleft slantright">&nbsp;</div>
</footer>

View File

@ -42,7 +42,12 @@
<% end %>
</div>
<%= render partial: 'layouts/footer' %>
<footer>
<div class="footer_title"><h2><%= yield(:footer_title) %></h2></div>
<div class="pd_logo"><%= image_tag("perficientdigital.png", alt:"Perficient Digital") %></div>
<div class="footer_yellow-bar slantleft slantright">&nbsp;</div>
</footer>
<!--[if ! lte IE 8]><!-->
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

View File

@ -38,6 +38,24 @@ class QuizControllerTest < ActionDispatch::IntegrationTest
assert_redirected_to question_path
assert session[:test_id].present?
assert assigns(:question), '@question not present'
assert assigns(:answer), '@answer not present'
assert assigns(:status), '@status not present'
end
test "should get summary" do
setup_auth candidates :dawn
get summary_path
assert_response :success
assert assigns(:quiz), '@quiz not present'
end
test "should redirect from summary" do
setup_auth candidates :roy
get summary_path
assert_redirected_to question_path
end
test "should get flash message on bad radio response" do
@ -48,6 +66,8 @@ class QuizControllerTest < ActionDispatch::IntegrationTest
assert_response :success
assert session[:test_id].present?
assert_equal qid, flash[:error]
assert assigns(:question), '@question not present'
assert assigns(:answer), '@answer not present'
end
test "should get flash message on bad text response" do
@ -58,6 +78,8 @@ class QuizControllerTest < ActionDispatch::IntegrationTest
assert_response :success
assert session[:test_id].present?
assert_equal qid, flash[:error]
assert assigns(:question), '@question not present'
assert assigns(:answer), '@answer not present'
end
test "should process checkbox" do
@ -67,6 +89,8 @@ class QuizControllerTest < ActionDispatch::IntegrationTest
assert_response :success
assert session[:test_id].present?
assert assigns(:question), '@question not present'
assert assigns(:answer), '@answer not present'
end
test 'should handle XHR update and complete progress' do
@ -77,6 +101,8 @@ class QuizControllerTest < ActionDispatch::IntegrationTest
assert_response :success
assert_match(/updated successfully/, JSON.parse(@response.body)['message'])
assert_equal 100, JSON.parse(@response.body)['progress']
assert assigns(:question), '@question not present'
assert assigns(:answer), '@answer not present'
end
test 'should handle XHR fail' do
@ -86,5 +112,7 @@ class QuizControllerTest < ActionDispatch::IntegrationTest
assert_response 400
assert_match(/select.*answer/i, JSON.parse(@response.body).join)
assert assigns(:question), '@question not present'
assert assigns(:answer), '@answer not present'
end
end

View File

@ -48,12 +48,14 @@ class RecruiterControllerTest < ActionDispatch::IntegrationTest
setup_auth
get recruiter_url
assert_response :success
assert assigns(:candidates), "@candidates not present"
end
test "should get new" do
setup_auth
get new_candidate_url
assert_response :success
assert assigns(:candidate), "@candidate not present"
end
test "should get create" do
@ -85,6 +87,7 @@ class RecruiterControllerTest < ActionDispatch::IntegrationTest
end
end
assert :success
assert assigns(:candidate), "@candidate not present"
assert_match(/failed.*save/i, flash[:error])
end
end

View File

@ -37,6 +37,7 @@ class ReviewControllerTest < ActionDispatch::IntegrationTest
setup_auth
get review_url
assert_response :success
assert assigns(:candidates), '@candidates not present'
end
test "should get index" do
@ -51,6 +52,9 @@ class ReviewControllerTest < ActionDispatch::IntegrationTest
get review_test_url(candidates(:richard).test_hash)
assert_response :success
assert assigns(:candidate), "@candidate not present"
assert assigns(:quiz), "@quiz not present"
assert assigns(:status), "@status not present"
end
test 'should logout and reset session' do