class PathGenerationTest
Attributes
app[R]
Public Class Methods
new()
click to toggle source
Calls superclass method
# File railties/test/path_generation_test.rb, line 62 def initialize super app = self @routes = TestSet.new ->(c) { app.controller = c } secrets.secret_key_base = "foo" secrets.secret_token = "foo" end
Public Instance Methods
send_request(uri_or_host, method, path, script_name = nil)
click to toggle source
# File railties/test/path_generation_test.rb, line 39 def send_request(uri_or_host, method, path, script_name = nil) host = uri_or_host.host unless path path ||= uri_or_host.path params = { "PATH_INFO" => path, "REQUEST_METHOD" => method, "HTTP_HOST" => host } params["SCRIPT_NAME"] = script_name if script_name status, headers, body = app.call(params) new_body = [] body.each { |part| new_body << part } body.close if body.respond_to? :close [status, headers, new_body] end
test_original_script_name()
click to toggle source
# File railties/test/path_generation_test.rb, line 56 def test_original_script_name original_logger = Quails.logger Quails.logger = Logger.new nil app = Class.new(Quails::Application) { attr_accessor :controller def initialize super app = self @routes = TestSet.new ->(c) { app.controller = c } secrets.secret_key_base = "foo" secrets.secret_token = "foo" end def app; routes; end } @app = app app.routes.draw { resource :blogs } url = URI("http://example.org/blogs") send_request(url, "GET", nil, "/FOO") assert_equal "/FOO/blogs", app.instance.controller.blogs_path send_request(url, "GET", nil) assert_equal "/blogs", app.instance.controller.blogs_path ensure Quails.logger = original_logger end