blob: f22b9fda3d84ae5cfe3c7a1407b8a663cc643ba7 (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# frozen_string_literal: true
require "isolation/abstract_unit"
module ApplicationTests
class UrlGenerationTest < ActiveSupport::TestCase
include ActiveSupport::Testing::Isolation
def app
Rails.application
end
test "it works" do
require "rails"
require "action_controller/railtie"
require "action_view/railtie"
class MyApp < Rails::Application
config.session_store :cookie_store, key: "_myapp_session"
config.active_support.deprecation = :log
config.eager_load = false
end
Rails.application.initialize!
class ::ApplicationController < ActionController::Base
end
class ::OmgController < ::ApplicationController
def index
render plain: omg_path
end
end
MyApp.routes.draw do
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
|