Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix controller_class_name for anonymous controllers. #6053

Closed
wants to merge 1 commit into from
Closed

Fix controller_class_name for anonymous controllers. #6053

wants to merge 1 commit into from

Conversation

mschuerig
Copy link
Contributor

TestCase#process generates an incorrect controller_class_name for anonymous classes. The name has a "_controller" suffix, which ought not to be there. This change simply removes that suffix.

@rafaelfranca
Copy link
Member

cc @pixeltrix

@josevalim
Copy link
Contributor

Can we have a test pls?

@mschuerig
Copy link
Contributor Author

On Sunday 29 April 2012, you wrote:

Can we have a test pls?

Not right now, sorry, I don't have the time right now. The existing
tests still pass, of course. Please consider the change and decide if it
is too obvious.

Michael

Michael Schuerig
mailto:michael@schuerig.de
http://www.schuerig.de/michael/

@pixeltrix
Copy link
Contributor

Whilst I agree that the controller suffix shouldn't be there, how is it breaking things for you? Changing it now may break some people's tests and I've been burned for that in the past

@mschuerig
Copy link
Contributor Author

On Sunday 29 April 2012, you wrote:

Whilst I agree that the controller suffix shouldn't be there, how is
it breaking things for you? Changing it now may break some people's
tests and I've been burned for that in the past

Simply put, if people have tests that use anonymous controllers, they
must be working around the existing behavior in some way, if they are
aware of it or not. The problem with the "_controller" suffix is, that
route caching uses nested hashes with keys like

[:action, "index"] and [:controller, "anonymous"]

A controller_name of "anonymous_controller" never matches such a key and
results in a routing error.

Michael

Michael Schuerig
mailto:michael@schuerig.de
http://www.schuerig.de/michael/

@josevalim
Copy link
Contributor

This needs to be fixed, even if people are relying on it, they are relying on wrong code.

pixeltrix added a commit that referenced this pull request Apr 29, 2012
@pixeltrix
Copy link
Contributor

@josevalim backport?

@pixeltrix
Copy link
Contributor

Fixed by 529a3ee - not backporting as it may break things

@pixeltrix pixeltrix closed this May 8, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants