Skip to content
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

Filter locale breaks default_url_options in tests (setting the Locale from URL Params) #80

Open
viktorianer opened this issue Dec 31, 2021 · 0 comments

Comments

@viktorianer
Copy link

In the Usage section, under Tests, it says that

RoutingFilter should not be enabled in functional tests by default.

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant