routing-filter wraps around the complex beast that the Rails routing system is, allowing for unseen flexibility and power in Rails URL recognition and generation.
rails _7.0.0_ new sample_app
rails generate scaffold Contact email
# run test, all passing
# add this gem
# configure it like described under [usage](https://github.com/svenfuchs/routing-filter#usage) section
# add `RoutingFilter.active = false` to test_helper.rb
# run tests again
rails test test/controllers/contacts_controller_test.rb
# it will fails with
Expected response to be a redirect to <http://www.example.com/contacts/980190963> but was a redirect to <http://www.example.com/en/contacts/980190963>.
Expected "http://www.example.com/contacts/980190963" to be === "http://www.example.com/en/contacts/980190963".
Expected behavior
When I add RoutingFilter.active = false to test_helper.rb all generated controller or route tests are passing.
or:
Add description in the README, how to use this gem with recommended way to setting the locale from URL params.
Actual behavior
In generated *ContactsControllerTest < ActionDispatch::IntegrationTest all assertions like assert_redirected_to contact_url(Contact.last) or assert_redirected_to contacts_url will fail.
Workaround
I find out, that instead of adding RoutingFilter.active = false to test_helper.rb I had to add RoutingFilter::Locale.include_default_locale = false.
In the Usage section, under Tests, it says that
And if I do so, it breaks the recommended way to Setting the Locale from URL Params, as described in the Rails I18n Guides.
Step to reproduce
Expected behavior
When I add
RoutingFilter.active = false
totest_helper.rb
all generated controller or route tests are passing.or:
Add description in the
README
, how to use this gem with recommended way to setting the locale from URL params.Actual behavior
In generated
*ContactsControllerTest < ActionDispatch::IntegrationTest
all assertions likeassert_redirected_to contact_url(Contact.last)
orassert_redirected_to contacts_url
will fail.Workaround
I find out, that instead of adding
RoutingFilter.active = false
totest_helper.rb
I had to addRoutingFilter::Locale.include_default_locale = false
.