1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/test/application/url_generation_test.rb

61 lines
1.5 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require "isolation/abstract_unit"
module ApplicationTests
2012-01-05 20:30:17 -05:00
class UrlGenerationTest < ActiveSupport::TestCase
include ActiveSupport::Testing::Isolation
def app
Rails.application
end
test "it works" do
require "rails"
require "action_controller/railtie"
2013-07-30 05:28:31 -04:00
require "action_view/railtie"
class MyApp < Rails::Application
2012-10-14 06:03:39 -04:00
config.session_store :cookie_store, key: "_myapp_session"
config.active_support.deprecation = :log
2012-10-18 13:33:40 -04:00
config.eager_load = false
config.hosts << proc { true }
config.secret_key_base = "b3c631c314c0bbca50c1b2843150fe33"
end
Rails.application.initialize!
class ::ApplicationController < ActionController::Base
end
class ::OmgController < ::ApplicationController
def index
render plain: omg_path
end
end
MyApp.routes.draw do
2012-10-14 06:03:39 -04:00
get "/" => "omg#index", as: :omg
end
require "rack/test"
extend Rack::Test::Methods
get "/"
assert_equal "/", last_response.body
end
def test_routes_know_the_relative_root
require "rails"
require "action_controller/railtie"
require "action_view/railtie"
relative_url = "/hello"
ENV["RAILS_RELATIVE_URL_ROOT"] = relative_url
app = Class.new(Rails::Application)
assert_equal relative_url, app.routes.relative_url_root
ENV["RAILS_RELATIVE_URL_ROOT"] = nil
end
end
end