-
Notifications
You must be signed in to change notification settings - Fork 9
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
Routing incorrectly matches documents #63
Comments
dtognazzini
added a commit
that referenced
this issue
Oct 4, 2014
fix Routing incorrectly matches documents issue and fix for #63
Released in 1.2.0 |
This was referenced Oct 4, 2014
This fix doesn't support handling mounted Rails engines. Reopening. |
@dtognazzini can we add engine test case in page_object_integration_test after revert #73 |
Yes, we should. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Consider the following code:
window.change_to
needs to load one of the documents above instead of using an on-demand load with a document proxy to ensure that thewindow.change_to
call fails if the window has a document not in the expected set. If this check is deferred until later, the calling code may never access the returned reference and thus the check would never be made.However, Rails routes is a precedence-order matching list and the first thing that matches, wins. So, in the above case, if the url is /books/new and we try to load a Books::ShowPage, it'll work because the show route will match the URL and use "new" as the :id parameter for the show named route.
So we have 2 options:
Keep the current load-now behavior and figure out how to match better such that loading ShowPage will fail for /books/new. This would involve running through the normal Rails route matching and somehow comparing the resulting match with whatever would match the ShowPage. A first try might be to run the route matching with the path defined for ShowPage. Unfortunately, generating the path is difficult, 'cause the ShowPage route has a required parameter which would have to be faked in order to get Rails' routes matching to work; this would have to be done for any arbitrary route.
Another idea, is to run all of the expected document types through the route matching and from the matching ones select whichever has the highest precedence. This would require changes to the Router and/or AePageObjects to support the idea of precedence. This support is a coupling between AePageObjects and the underlying router, in this case Rails'. Of course, the document loading could be further generalized to support this concept.
Keep the current load-now behavior to get the immediate failure when there are no matches, but run the route matching later again from the DocumentProxy when the page is accessed. This works great for explicit casts because it doesn't care about the previous loading that happened with the
window.change_to
call. Implicit casts works as well, as with implicit casts the contract is that the first specified expected page is used for implicit casts.The downside of this method is that it only works when you call
window.change_to
with multiple pages. It doesn't work with single-argwindow.change_to
calls:This code does not raise an error because Books::ShowPage can recognize Books::NewPage's routes.
Then again, it's not really clear how either solution can handle the single-arg case.
The text was updated successfully, but these errors were encountered: