Comments (12)
I also had issue with 3.2.3.
from routing-filter.
Indeed I have the same issue when running rspec tests in Rails 3.2.3. Rails 3.2.2 works correctly.
from routing-filter.
Could one of you provide a failing test case or a small rails app exhibiting this behaviour?
from routing-filter.
I couldn't reproduce the problem by adding a test case to router-filter unit tests. It seem to appear only in combination of rails 3.2.3 and rspec.
This line:
get :edit, id: situation.id, locale: :de
will properly set the locale in rails 3.2.2 but not 3.2.3.
In non test mode locale params seems to be recognized properly even in rails 3.2.3.
from routing-filter.
I've tracked the source of the problem down to this commit in rails/rails@275ee0d
The merging of the additional controller parameters in the test environment has been removed there.
Haven't found a way around that though. Any ideas are appreciated
from routing-filter.
I'm running into this as well, any updates or workarounds?
from routing-filter.
Use Rails 3.2.2 :)
from routing-filter.
Changing line 64 of filters/locale.rb from
locale = params.delete(:locale)
to
locale = params[:locale]
seems to fix this issue for RSpec at least, but I can't tell if it's going to affect anything else (filtered routes are still working properly in my development app) and I can't get the routing-filter tests to run here.
from routing-filter.
Ok, I just spent a couple of hours to this issue and my conclusion is that it was a lucky coincidence that these tests ever worked. What happend on Rails <= 3.2.2 is basically this:
- Duplicate the params hash and directly assign it as the ActionController::TestCase params hash
- Call build_request_uri
- RoutingFilter gets called and removes params from the hash depending on the active filters
- The generated Url gets assigned
- Action within the tested controller gets dispatched without calling the router
- Tests see the param hash from step 1 - not the params hash the real router would have generated
Rails 3.2.3 removes step 1, so now some params get lost as they get encoded in the url but not decoded by the router.
The quick and easy workaround is adding
RoutingFilter.active = false
to your test_helper.rb or spec_helper.rb. If you are running tests for the routing you can re-enable routingfilter there, the router and thus routing-filter gets called correctly in those tests.
from routing-filter.
Cool. Thanks for the fix and all the effort!
On 7 mei 2012, at 23:15, [email protected] wrote:
Ok, I just spent a couple of hours to this issue and my conclusion is that it was a lucky coincidence that these tests ever worked. What happend on Rails <= 3.2.2 is basically this:
- Duplicate the params hash and directly assign it as the ActionController::TestCase params hash
- Call build_request_uri
- RoutingFilter gets called and removes params from the hash depending on the active filters
- The generated Url gets assigned
- Action within the tested controller gets dispatched without calling the router
- Tests see the param hash from step 1 - not the params hash the real router would have generated
Since the filters never got tested the quick and easy workaround is adding
RoutingFilter.active = falseto the test_helper.rb or spec_helper.rb
If you are running tests for the routing you can re-enable routingfilter there, the router and thus routing-filter gets called correctly in those tests.
Reply to this email directly or view it on GitHub:
#36 (comment)
from routing-filter.
Closing since the cause is in upstream rails, it's not a real bug and a viable workaround is available and documented.
from routing-filter.
👍 Thanks for figuring this out, yabawock!
from routing-filter.
Related Issues (20)
- 0.4.0.pre Does Not Do Proper Routing HOT 5
- Didn't work on rails 4 HOT 2
- Is this gem support alive? HOT 2
- Devise "Not found. Authentication passthru."
- rails4 undefined local variable or method map HOT 5
- Set :include_default_locale to true ignored HOT 5
- Support for case insensitive locales HOT 9
- Is there a plan to support Rails 5 ?
- New release ? HOT 8
- How to use filter in a block?
- I'm not able to make a custom filter work
- Routing Error instead of fallback to en
- Avoiding duplicate content SEO penalty HOT 2
- Why default locale is not fallen back to? HOT 1
- Update routing-filter to allow rails 5.2
- Won't work with Rails 6.1 HOT 5
- Please release new gem version HOT 4
- Filter locale breaks default_url_options in tests (setting the Locale from URL Params)
- README and repo description (on github) reference artweb-design HOT 1
- routing-filter doesn't seem to work with rails 7.1 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from routing-filter.