This project is archived and is in readonly mode.
Use #to_param in generated controller tests.
-
Chad Woolley
+1
-
Zach Brock
+1
-
John Barnette
Doesn't
to_paramget called automatically? What about:def test_should_get_show get :show, :id => articles(:one) endOr have I been Doing It Wrong all this time? :)
-
Pat Nakajima
So in the fresh Rails app I just generated, yours seems to work unless
to_paramis overridden. I think it might be worthwhile to putto_paramin the scaffold anyway, since it'll teach people "the right way". -
John Barnette
Also, looks like the call to
to_parammakes the log dump of the request parameters in test a lot easier to read. I'm +1 on this change, not that it's needed at this point. -
Adam Milligan
+1
The whole "it's called an ID but it's not an ID" thing is confusing enough as it is. No need to make it worse by generating wrong code.
-
David Yeu
+1
-
Jeff Dean
+1
-
Pat Nakajima
I should mention that all tests continue to pass with this patch (though there didn't seem to be any coverage specifically related to this change).
-
Repository
- State changed from new to committed
(from [0c956443964a20cbcc122e2d8c429b0cbb121828]) Changed scaffold generated controller tests to use #to_param.
Before, the generated controller tests were calling #id, which can change over time, making for brittle tests.
Signed-off-by: Michael Koziarski michael@koziarski.com [#1913 Use #to_param in generated controller tests. state:committed] http://github.com/rails/rails/co...
