bploetz / versionist

A plugin for versioning Rails based RESTful APIs.
MIT License
972 stars 51 forks source link

Only generate the default strategy routes once. #52

Closed Altonymous closed 10 years ago

Altonymous commented 11 years ago

This should address this issue: https://github.com/bploetz/versionist/issues/46

Altonymous commented 11 years ago

All Rails 4_0 specs pass. The other versions fail with this error:

1) Versionist::Routing#api_version Accept header version substring matches should route to the correct controller when format specified via accept header
   Failure/Error: assert_equal 'application/json', response.content_type
   MiniTest::Assertion:
     <"application/json"> expected but was
     <nil>.
   # (eval):2:in `assert_equal'
   # ./spec/api_routing_spec.rb:730:in `block (4 levels) in <top (required)>'

I'm not sure if that was there before my fork or not... and I'm not sure what the error is related to. I'll be happy to fix if it is related to my chances and you can give me a brief overview of what's happening.

bploetz commented 11 years ago

@Altonymous That specific test that's failing asserts that when you specify both a content type AND a version in the Accept header, that it both routes to the correct place (based on the version) and returns the correct content type (i.e. that they can co-exist).

https://github.com/bploetz/versionist/blob/master/spec/api_routing_spec.rb#L726

That error you're getting suggests that your fix broke this logic. See my comment in #46 asking for more details to help nail down the issue you guys are seeing (I'm unable to reproduce this locally).

Altonymous commented 10 years ago

Here's a sample application that reproduces the issue.

https://github.com/Altonymous/authentication

Just run rake routes after doing a bundle install

Altonymous commented 10 years ago

Looks like it's a combination of devise and versionist. Been long enough I don't remember the particulars. But hopefully this helps you reproduce it.

bploetz commented 10 years ago

versionist 1.3.0 has been pushed to rubygems.org with this fix.