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

60 lines
1.4 KiB
Ruby
Raw Normal View History

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
boot_rails
require "rails"
require "action_controller/railtie"
2013-07-30 05:28:31 -04:00
require "action_view/railtie"
class MyApp < Rails::Application
secrets.secret_key_base = "3b7cd727ee24e8444053437c36cc66c4"
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
end
Rails.application.initialize!
class ::ApplicationController < ActionController::Base
end
class ::OmgController < ::ApplicationController
def index
2012-10-14 06:03:39 -04:00
render text: 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
boot_rails
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