Wardrop/Scorched — pull request #17 by andreypopp (2013-07-31 09:12:29+00:00)
Title: Fix URL generation in subcontrollers

Currently when calling subcontrollers Scorched mangle `PATH_INFO` but doesn't do anything with `SCRIPT_NAME` which violates `SCRIPT_NAME + PATH_INFO = url path` invariant. This also makes URL generation non-intuitive cause it always generate URL as they are relative to root controller.

I added specs (which currently fail) which define that subcontrollers should operate as independent Rack apps and generate URL relative to themselves.

I think this is the sane default behaviour because it enables `Scorched::Controller` to be "relocatable" — to be independent of the URL it is mapped to. I think one can also override this behaviour if by choosing to use `scorched.script_name` (to be introduced) instead of mangled `SCRIPT_NAME`.

The only place I would like to keep the current behaviour is controllers defined with `controller` helper. Because they are not "relocatable" and don't need to be such they are expected to produce URLs relative to their parent. I think we can introduce optional argument to `map` which would define if Scorched should treat subcontroller as a separate Rack app or just as a namespace.

* [ ] mangle `SCRIPT_NAME` along with `PATH_INFO` when calling subcontrollers
* [ ] introduce `scorched.script_name` which stores original `SCRIPT_NAME` value
* [ ] decide and implement if need special behaviour for controllers mounted with `controller` helpers

This pull request builds up on #16