bploetz / versionist

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

Invoke test_path and older_than_rails_5 methods explicitly in generators #85

Closed archferns closed 6 years ago

archferns commented 6 years ago

The generators were failing in Rails 5.1 due to the implicit calls to test_path and older_than_rails_5? This commit fixes the generators by making explicit calls to Versionist.test_path and Versionist.older_than_rails_5?

bploetz commented 6 years ago

Thanks for this @archferns . Note that this is broken in general, not just in Rails 5.1.

> rails -v
Rails 4.2.4

> rails generate versionist:new_api_version v2 V2 --header=name:Accept value:"application/vnd.mycompany.com; version=2"Running via Spring preloader in process 16987
       route  api_version(:module => "V2", :header => {:name => "Accept", :value => "application/vnd.mycompany.com; version=2"}) do
  end
       exist  app/controllers/v2
   identical  app/controllers/v2/base_controller.rb
/Users/bploetz/.rvm/gems/ruby-2.2.2@versionist-test/gems/versionist-1.6.0/lib/generators/versionist/new_api_version/new_api_version_generator.rb:67:in `block in add_controller_base_tests': undefined local variable or method `test_path' for #<Versionist::NewApiVersionGenerator:0x007ffc84ecdc30> (NameError)
> rails -v
Rails 5.1.4

ails generate versionist:new_api_version v1 V1 --header=name:Accept value:"application/vnd.mycompany.com; version=1"
Running via Spring preloader in process 48302
       route  api_version(:module => "V1", :header => {:name => "Accept", :value => "application/vnd.mycompany.com; version=1"}) do
  end
      create  app/controllers/v1
      create  app/controllers/v1/base_controller.rb
/Users/bploetz/.rvm/gems/ruby-2.2.5@versionist-test-rails51/gems/versionist-1.6.0/lib/generators/versionist/new_api_version/new_api_version_generator.rb:67:in `block in add_controller_base_tests': undefined local variable or method `test_path' for #<Versionist::NewApiVersionGenerator:0x007fdafd8097f8> (NameError)
bploetz commented 6 years ago

versionist 1.6.1 has been released with this fix.

Cheers.

archferns commented 6 years ago

Thanks, that's great news!