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

Does not properly generate route with mandatory :format segment #57

Closed
khustochka opened this issue May 23, 2014 · 3 comments
Closed

Does not properly generate route with mandatory :format segment #57

khustochka opened this issue May 23, 2014 · 3 comments

Comments

@khustochka
Copy link
Contributor

I have added the following test:

  def test_route_with_mandatory_format
    draw_routes do
      localized do
        get 'people.:format', :to => 'people#index'
      end
    end

    assert_routing '/es/gente.xml', :controller => 'people', :action => 'index', :format => 'xml', :locale => 'es'
    assert_routing '/people.xml', :controller => 'people', :action => 'index', :format => 'xml', :locale => 'en'
  end

It fails with

TranslateRoutesTest#test_formatted_route [/home/vk/route_translator/test/routing_test.rb:297]:
No route matches "/es/gente.xml"

(The same for /people.xml - no route matches).

But if I change .:format to (.:format) it works.

@khustochka
Copy link
Contributor Author

I did some investigation and it looks like that when you do unlocalized:

get 'people.:format', :to => 'people#index'

it generates route GET /people.:format people#index (as shown in rake routes).

But when you do localized:

      localized do
        get 'people.:format', :to => 'people#index'
      end

It generates the routes without :format!

GET /es/people people#index {:locale=>"es"}
GET /people people#index {:locale=>"en"}

@khustochka
Copy link
Contributor Author

I made a pull request #58 to fix this.

@gi-lunaweb
Copy link
Collaborator

The pull request is merged, thanks. I just released route_translator 3.2.3 that include your fix.

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

2 participants