aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application/middleware/show_exceptions_test.rb
blob: e3f27f63c33f6cbc2f127c3fa58abbbfc4ab00bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'isolation/abstract_unit'

module ApplicationTests
  class ShowExceptionsTest < Test::Unit::TestCase
    include ActiveSupport::Testing::Isolation

    def setup
      build_app
      boot_rails
      FileUtils.rm_rf "#{app_path}/config/environments"
    end

    def teardown
      teardown_app
    end

    def app
      @app ||= Rails.application
    end

    test "unspecified route when set action_dispatch.show_exceptions to false" do
      make_basic_app do |app|
        app.config.action_dispatch.show_exceptions = false
      end

      assert_raise(ActionController::RoutingError) do
        get '/foo'
      end
    end

    test "unspecified route when set action_dispatch.show_exceptions to true" do
      make_basic_app do |app|
        app.config.action_dispatch.show_exceptions = true
      end

      assert_nothing_raised(ActionController::RoutingError) do
        get '/foo'
      end
    end
  end
end