
Redirection/Visits to files in rails public/ always fail
Reported by Joseph Wilk | May 27th, 2008 @ 08:19 AM
http://www.ruby-forum.com/topic/...
I have a form in a rails app which either redirects to a static HTML file in public or to a controller.
Fetches to public files always fails as the route does not match any controllers.
This is not a Webrat bug but it would be nice if it worked. (And I wont not have to use gulp Selenium)
I've been working on this for the last couple of days following what Josh suggested
"can look at getting webrat to recognize the redirect to file outside the scope of the rails environment."
I've fixed basic 'visits static_file.html'.
I'll attach the patch so far soon but I'm still working on how to deal with more than one redirect.
I.e
post form -> EditController -> SiteController -> public html.
I can detect the error that the rails app failed to resolve a page:
session.send "#{method}", url, data || {}
And hence know that it could be a public/page. But I've got to resolve the URL to get to the last redirection so I know which url to test against the public/ folder
Comments and changes to this ticket
-
Joseph Wilk May 30th, 2008 @ 01:32 PM
Heres my patch so far.
I've opened a can of worms slightly by needing webrat/rails loaded for fake TestSession. Which means that the rcov coverage has dropped below 96.9% (91.3%).
I understand now why the rails integration tests are commented out :)
I was thinking I would create a fake TestResponse to go along with the TestSession. That would remove the rails dependency and move Rcov backup to 96.9%.
So I'll add that to the patch later, but here it is just for review. Check theres nothing I'm doing thats crazy.
-
Joseph Wilk June 2nd, 2008 @ 06:41 AM
I faked the AbstractResponse rather than the TestResponse. Hence faking the bit that required rails (AbstractResponse).
>rake verify_rcov
>
>98 examples, 0 failures
>Coverage: 97.2% (threshold: 96.9%)
Aswell as patch issued a pull from my fork of Webrat:
git://github.com/JoeSniff/webrat.git
Commit Summary
----
Ensured that any actions performed on files in the public/ folder of an application will succeed. Previously: visits '/index.html' would fail. This is because only if a URL was matched by a controller would it succeed. Rails Integration tests dictate this. So this patch lets rails fail and then checks itself whether it can resolve the URL inside the public folder. If so it magics up a response showing the request succeeded.
----
-
gaffo January 6th, 2009 @ 11:58 PM
- Tag set to featurerequest, patch
- State changed from new to resolved
I tested this out on http://github.com/gaffo/webrat_r... branch lh_10
It doesn't seem to be there any more.
If it still is, please send a pull request or a patch to the test app to help us figure out what the bug is.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Ruby Acceptance Testing for Web applications.