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

Added some failing tests with named_route and url_for: why do these fail? #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jensb
Copy link

@jensb jensb commented Oct 9, 2011

Hello,

when using named_route paths with multiple parameters, translations are not detected (so paths are not translated). Attached is a patch which adds four failing tests, to test this.

Failures:

1) localized_routes routes in loop and controller blocks translated named route, from
 Failure/Error: routes.send(:from_search_path, :country => 'DE', :city => 'HH', :type => 'from').should == '/von/DE/HH'
   expected: "/von/DE/HH"
        got: "/from/DE/HH" (using ==)
 # ./spec/i18n_routing/i18n_spec.rb:259

2) localized_routes routes in loop and controller blocks translated named route, to
 Failure/Error: routes.send(:to_search_path, :country => 'DE', :city => 'HH', :type => 'to').should == '/nach/DE/HH'
   expected: "/nach/DE/HH"
        got: "/to/DE/HH" (using ==)
 # ./spec/i18n_routing/i18n_spec.rb:262

3) localized_routes routes in loop and controller blocks translated url_for, from
 Failure/Error: url_for(:controller => :search, :action => :show, :country => 'DE', :city => 'HH', :type => 'from').should == '/von/DE/HH'
   expected: "/von/DE/HH"
        got: "/from/DE/HH" (using ==)
 # ./spec/i18n_routing/i18n_spec.rb:265

4) localized_routes routes in loop and controller blocks translated url_for, to
 Failure/Error: url_for(:controller => :search, :action => :show, :country => 'DE', :city => 'HH', :type => 'to').should == '/nach/DE/HH'
   expected: "/nach/DE/HH"
        got: "/to/DE/HH" (using ==)
 # ./spec/i18n_routing/i18n_spec.rb:268

@kwi
Copy link
Owner

kwi commented Oct 10, 2011

Hi,

Thanks for finding these bugs, I have currently not a lot of time to work on
this, so I will try to do it soon, but in the meantime, don't hesitate to
try to hack on it !

Thanks!

2011/10/9 jensb <
[email protected]>

Hello,

when using named_route paths with multiple parameters, translations are not
detected (so paths are not translated). Attached is a patch which adds four
failing tests, to test this.

Failures:

  1. localized_routes routes in loop and controller blocks translated
    named route, from
    Failure/Error: routes.send(:from_search_path, :country => 'DE', :city
    => 'HH', :type => 'from').should == '/von/DE/HH'
    expected: "/von/DE/HH"
    got: "/from/DE/HH" (using ==)
    # ./spec/i18n_routing/i18n_spec.rb:259

  2. localized_routes routes in loop and controller blocks translated
    named route, to
    Failure/Error: routes.send(:to_search_path, :country => 'DE', :city =>
    'HH', :type => 'to').should == '/nach/DE/HH'
    expected: "/nach/DE/HH"
    got: "/to/DE/HH" (using ==)
    # ./spec/i18n_routing/i18n_spec.rb:262

  3. localized_routes routes in loop and controller blocks translated
    url_for, from
    Failure/Error: url_for(:controller => :search, :action => :show,
    :country => 'DE', :city => 'HH', :type => 'from').should == '/von/DE/HH'
    expected: "/von/DE/HH"
    got: "/from/DE/HH" (using ==)
    # ./spec/i18n_routing/i18n_spec.rb:265

  4. localized_routes routes in loop and controller blocks translated
    url_for, to
    Failure/Error: url_for(:controller => :search, :action => :show,
    :country => 'DE', :city => 'HH', :type => 'to').should == '/nach/DE/HH'
    expected: "/nach/DE/HH"
    got: "/to/DE/HH" (using ==)
    # ./spec/i18n_routing/i18n_spec.rb:268

You can merge this Pull Request by running:

git pull https://github.com/jensb/i18n_routing master

Or you can view, comment on it, or merge it online at:

#27

-- Commit Summary --

  • Added failing test for named routes with extra parameters

-- File Changes --

M spec/i18n_routing/i18n_spec.rb (56)
M spec/locales/de.yml (4)

-- Patch Links --

https://github.com/kwi/i18n_routing/pull/27.patch
https://github.com/kwi/i18n_routing/pull/27.diff

Reply to this email directly or view it on GitHub:
#27

@jensb
Copy link
Author

jensb commented Oct 11, 2011

Hi,

thanks for replyling! I dug some more and found out that your plugin stops working when there are constraints on parameters. E.g.

match "/route/:country/:city" => "search#show", :constraints => { :city => /[A-Za-z0-9_-]/ }

Different parameter separators or SEO optimized paths are OK - only constraints do not work. The translation is found (when using :verbose => true) but it is not used.

If you can point me to where this might go wrong, I'll spray debugging output over my fork and have another look at it.

@jensb
Copy link
Author

jensb commented Oct 12, 2011

Also, important to note is that while using constraints, only url_for does not work, while named routes translate perfectly and use the constraints. So, the constraints options are not lost, but somehow, they prevent translated routes from being created properly.

Please provide some assistance in finding this bug, I'll be happy to create tests and patches for you to pull once I know where to fix it. I don't have too much experience with Rails's internals, so I probably won't find it on my own.

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants