2017-08-14 13:08:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 13:16:09 -04:00
|
|
|
require "isolation/abstract_unit"
|
|
|
|
require "rack/test"
|
2013-04-10 03:07:31 -04:00
|
|
|
|
|
|
|
module ApplicationTests
|
2018-04-03 17:12:20 -04:00
|
|
|
class RenderingTest < ActiveSupport::TestCase
|
2013-04-10 03:07:31 -04:00
|
|
|
include ActiveSupport::Testing::Isolation
|
|
|
|
include Rack::Test::Methods
|
|
|
|
|
|
|
|
def setup
|
|
|
|
build_app
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
teardown_app
|
|
|
|
end
|
|
|
|
|
|
|
|
test "Unknown format falls back to HTML template" do
|
2016-08-06 13:16:09 -04:00
|
|
|
app_file "config/routes.rb", <<-RUBY
|
2013-06-09 22:47:07 -04:00
|
|
|
Rails.application.routes.draw do
|
2013-04-10 03:07:31 -04:00
|
|
|
get 'pages/:id', to: 'pages#show'
|
|
|
|
end
|
|
|
|
RUBY
|
|
|
|
|
2016-08-06 13:16:09 -04:00
|
|
|
app_file "app/controllers/pages_controller.rb", <<-RUBY
|
2013-04-10 03:07:31 -04:00
|
|
|
class PagesController < ApplicationController
|
|
|
|
layout false
|
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
end
|
|
|
|
RUBY
|
|
|
|
|
2016-08-06 13:16:09 -04:00
|
|
|
app_file "app/views/pages/show.html.erb", <<-RUBY
|
2013-04-10 03:07:31 -04:00
|
|
|
<%= params[:id] %>
|
|
|
|
RUBY
|
|
|
|
|
2016-08-06 13:16:09 -04:00
|
|
|
get "/pages/foo"
|
2013-04-10 03:07:31 -04:00
|
|
|
assert_equal 200, last_response.status
|
|
|
|
|
2016-08-06 13:16:09 -04:00
|
|
|
get "/pages/foo.bar"
|
2013-04-10 03:07:31 -04:00
|
|
|
assert_equal 200, last_response.status
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|