From a741152e33f6a681113818418ad0f898f2d04697 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 20 Mar 2017 11:16:21 +0100 Subject: fix: 404 for missing pages template - fixes #9 --- app/controllers/pages_controller.rb | 2 ++ test/integration/key_discovery_test.rb | 23 ----------------------- test/integration/regression/key_discovery_test.rb | 23 +++++++++++++++++++++++ test/integration/regression/provider_info_test.rb | 20 ++++++++++++++++++++ 4 files changed, 45 insertions(+), 23 deletions(-) delete mode 100644 test/integration/key_discovery_test.rb create mode 100644 test/integration/regression/key_discovery_test.rb create mode 100644 test/integration/regression/provider_info_test.rb diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index b9c601a..4508450 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -9,6 +9,8 @@ class PagesController < ApplicationController def show @show_navigation = false render page_name + rescue ActionView::MissingTemplate + raise ActionController::RoutingError.new('Not Found') end private diff --git a/test/integration/key_discovery_test.rb b/test/integration/key_discovery_test.rb deleted file mode 100644 index 2a38a78..0000000 --- a/test/integration/key_discovery_test.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'test_helper' - -# This is not really a browser test - key discovery is used from bitmask. -# However we need to make sure to test the full rack stack to replicate -# exception handling. -class KeyDiscoveryTest < RackStackTest - include Capybara::DSL - - setup do - # make sure we test the whole stack... - Capybara.current_driver = Capybara.javascript_driver - end - - teardown do - # Revert Capybara.current_driver to Capybara.default_driver - Capybara.use_default_driver - end - - def test_404_on_non_existing_user - visit '/key/asjkholifweatg' - assert_equal 404, status_code - end -end diff --git a/test/integration/regression/key_discovery_test.rb b/test/integration/regression/key_discovery_test.rb new file mode 100644 index 0000000..2a38a78 --- /dev/null +++ b/test/integration/regression/key_discovery_test.rb @@ -0,0 +1,23 @@ +require 'test_helper' + +# This is not really a browser test - key discovery is used from bitmask. +# However we need to make sure to test the full rack stack to replicate +# exception handling. +class KeyDiscoveryTest < RackStackTest + include Capybara::DSL + + setup do + # make sure we test the whole stack... + Capybara.current_driver = Capybara.javascript_driver + end + + teardown do + # Revert Capybara.current_driver to Capybara.default_driver + Capybara.use_default_driver + end + + def test_404_on_non_existing_user + visit '/key/asjkholifweatg' + assert_equal 404, status_code + end +end diff --git a/test/integration/regression/provider_info_test.rb b/test/integration/regression/provider_info_test.rb new file mode 100644 index 0000000..2aaf6f6 --- /dev/null +++ b/test/integration/regression/provider_info_test.rb @@ -0,0 +1,20 @@ +require 'test_helper' + +class ProviderInfoTest < BrowserIntegrationTest + + def test_404_on_missing_page + visit '/about' + assert_equal 404, status_code + end + + def test_404_on_missing_language_page + visit '/de/about' + assert_equal 404, status_code + end + + def test_404_en_fallback + visit '/de/bye' + assert_equal 200, status_code + end + +end -- cgit v1.2.3