1
0
mirror of https://github.com/projekteuler/projekteuler.git synced 2026-01-27 02:28:50 +01:00

Add redirects, update test types

This commit is contained in:
2017-11-26 14:32:18 +01:00
parent c69eb788ef
commit b5697eff56
7 changed files with 39 additions and 27 deletions

View File

@@ -26,4 +26,9 @@ class AboutControllerTest < ActionDispatch::IntegrationTest
assert_response :success
end
test "should redirect about pages" do
get '/about=roman_numerals'
assert_redirected_to about_roman_numerals_url
end
end

View File

@@ -1,26 +1,26 @@
require 'test_helper'
class Admin::DashboardControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
class Admin::DashboardControllerTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
setup do
login
end
test "should get index" do
get :index
get admin_dashboard_index_url
assert_response :success
end
test "should post new problem count" do
post :update_problem_count, params: { problem_count: 15 }
assert_redirected_to controller: 'admin/dashboard', action: 'index'
post admin_dashboard_update_problem_count_url(problem_count: 15)
assert_redirected_to admin_dashboard_index_url
assert_equal 15, Problem.count
end
test "should fail incorrect problem count" do
post :update_problem_count, params: { problem_count: 2 }
assert_redirected_to controller: 'admin/dashboard', action: 'index'
post admin_dashboard_update_problem_count_url(problem_count: 2)
assert_redirected_to admin_dashboard_index_url
assert_equal 3, Problem.count
end

View File

@@ -1,20 +1,20 @@
require 'test_helper'
class Admin::TranslationsControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
class Admin::TranslationsControllerTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
setup do
login
@translation = translations(:translation_one)
end
test "should get index" do
get :index
get admin_translations_url
assert_response :success
assert_not_nil assigns(:translations)
end
test "should show translation" do
get :show, params: { id: @translation }
get admin_translation_url(id: @translation)
assert_response :success
end

View File

@@ -1,21 +1,25 @@
require 'test_helper'
class ProblemsControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
class ProblemsControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get :index
get problems_url
assert_response :success
end
test "should get show" do
get :show, params: { id: 1 }
get problem_url(id: 1)
assert_response :success
end
test "should get untranslated problem" do
get :show, params: { id: 3 }
get problem_url(id: 3)
assert_response :success
end
test "should redirect to correct problem" do
get '/problem=2'
assert_redirected_to problem_path(id: 2)
end
end

View File

@@ -1,8 +1,6 @@
require 'test_helper'
class TranslationsControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
class TranslationsControllerTest < ActionDispatch::IntegrationTest
setup do
@update = {
title: 'New title',
@@ -15,18 +13,18 @@ class TranslationsControllerTest < ActionController::TestCase
end
test "should get new for translated problem" do
get :new, params: { problem_id: 1 }
get new_problem_translation_url(problem_id: 1)
assert_response :success
end
test "should get new for untranslated problem" do
get :new, params: { problem_id: 3 }
get new_problem_translation_url(problem_id: 3)
assert_response :success
end
test "should create translation" do
assert_difference('Translation.count') do
post :create, params: { problem_id: 1, translation: @update }
post problem_translations_url(problem_id: 1, translation: @update)
end
assert_redirected_to problem_path(id: 1)
@@ -34,7 +32,7 @@ class TranslationsControllerTest < ActionController::TestCase
test "should not create incorrect translation" do
assert_no_difference('Translation.count') do
post :create, params: { problem_id: 1, translation: @incorrect }
post problem_translations_url(problem_id: 1, translation: @incorrect)
end
end
end