From d91fb4867e630be3947d7f5c67066eb60b10906a Mon Sep 17 00:00:00 2001 From: Vasiliy Ermolovich Date: Sat, 7 Jul 2018 17:25:33 +0300 Subject: [PATCH] Update dependencies and make it compatible. --- .travis.yml | 22 +++++++---------- Gemfile | 15 +----------- Gemfile.rails50 | 6 +++++ Gemfile.rails51 | 6 +++++ README.md | 4 ++-- api-versions.gemspec | 4 ++-- .../app/controllers/api/v1/bar_controller.rb | 5 +++- .../app/controllers/api/v2/foo_controller.rb | 5 +++- .../api/v3/nests/nested_controller.rb | 2 +- .../app/controllers/errors_controller.rb | 2 +- spec/routing_spec.rb | 24 +++++++++---------- 11 files changed, 48 insertions(+), 47 deletions(-) create mode 100644 Gemfile.rails50 create mode 100644 Gemfile.rails51 diff --git a/.travis.yml b/.travis.yml index 90996ec..a59d748 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,18 @@ language: ruby rvm: - - 1.9.3 - - 2.0.0 + - 2.2.9 + - 2.3.7 + - 2.4.4 + - 2.5.1 + +gemfile: + - Gemfile + - Gemfile.rails50 + - Gemfile.rails51 notifications: email: recipients: - api-versions@erich.erichmenge.com - me@davidcel.is -env: - - RAILS_VERSION=3-0-stable - - RAILS_VERSION=3-1-stable - - RAILS_VERSION=3-2-stable - - RAILS_VERSION=4-0-stable - - RAILS_VERSION=4.0.0 - - RAILS_VERSION=master - -matrix: - allow_failures: - - env: RAILS_VERSION=master diff --git a/Gemfile b/Gemfile index 4e37a18..172c571 100644 --- a/Gemfile +++ b/Gemfile @@ -3,17 +3,4 @@ source "http://rubygems.org" # Specify your gem's dependencies in api-versions.gemspec gemspec -case ENV['RAILS_VERSION'] -when /master/ - gem "rails", github: "rails/rails" -when /4-0-stable/ - gem "rails", github: "rails/rails", branch: "4-0-stable" -when /3-2-stable/ - gem "rails", github: "rails/rails", branch: "3-2-stable" -when /3-1-stable/ - gem "rails", github: "rails/rails", branch: "3-1-stable" -when /3-0-stable/ - gem "rails", github: "rails/rails", branch: "3-0-stable" -else - gem "rails", ENV['RAILS_VERSION'] -end +gem 'rails', '~> 5.2' diff --git a/Gemfile.rails50 b/Gemfile.rails50 new file mode 100644 index 0000000..a9a2514 --- /dev/null +++ b/Gemfile.rails50 @@ -0,0 +1,6 @@ +source "http://rubygems.org" + +# Specify your gem's dependencies in api-versions.gemspec +gemspec + +gem 'rails', '~> 5.0' diff --git a/Gemfile.rails51 b/Gemfile.rails51 new file mode 100644 index 0000000..76d5fbd --- /dev/null +++ b/Gemfile.rails51 @@ -0,0 +1,6 @@ +source "http://rubygems.org" + +# Specify your gem's dependencies in api-versions.gemspec +gemspec + +gem 'rails', '~> 5.1' diff --git a/README.md b/README.md index 2c5f2da..18fd5eb 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ [![Code Climate](https://codeclimate.com/github/erichmenge/api-versions.png)](https://codeclimate.com/github/erichmenge/api-versions) ### Requirements -* Rails 4 or Rails 3 -* Ruby 1.9 or greater +* Rails 5.0+ +* Ruby 2.2+ #### api-versions is a Gem to help you manage your Rails API endpoints. diff --git a/api-versions.gemspec b/api-versions.gemspec index 6ef592e..826cfaf 100644 --- a/api-versions.gemspec +++ b/api-versions.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.add_dependency('actionpack', '>= 3.0') s.add_dependency('activesupport', '>= 3.0') - s.add_development_dependency "rspec-rails", "~> 2.0" - s.add_development_dependency 'ammeter', '0.2.5' + s.add_development_dependency "rspec-rails", "~> 3.7" + s.add_development_dependency 'ammeter', '~> 1.1' s.add_development_dependency "coveralls" end diff --git a/spec/dummy/app/controllers/api/v1/bar_controller.rb b/spec/dummy/app/controllers/api/v1/bar_controller.rb index 98385b5..3f593c5 100644 --- a/spec/dummy/app/controllers/api/v1/bar_controller.rb +++ b/spec/dummy/app/controllers/api/v1/bar_controller.rb @@ -1,5 +1,8 @@ class Api::V1::BarController < ActionController::Base def new - render nothing: true + respond_to do |format| + format.json { render json: {} } + format.xml { render xml: {} } + end end end diff --git a/spec/dummy/app/controllers/api/v2/foo_controller.rb b/spec/dummy/app/controllers/api/v2/foo_controller.rb index 8cf5339..5809cd7 100644 --- a/spec/dummy/app/controllers/api/v2/foo_controller.rb +++ b/spec/dummy/app/controllers/api/v2/foo_controller.rb @@ -1,5 +1,8 @@ class Api::V2::FooController < ActionController::Base def new - render nothing: true + respond_to do |format| + format.json { render json: {} } + format.xml { render xml: {} } + end end end diff --git a/spec/dummy/app/controllers/api/v3/nests/nested_controller.rb b/spec/dummy/app/controllers/api/v3/nests/nested_controller.rb index de60551..e909171 100644 --- a/spec/dummy/app/controllers/api/v3/nests/nested_controller.rb +++ b/spec/dummy/app/controllers/api/v3/nests/nested_controller.rb @@ -1,5 +1,5 @@ class Api::V3::Nests::NestedController < ActionController::Base def new - render nothing: true + render body: nil end end diff --git a/spec/dummy/app/controllers/errors_controller.rb b/spec/dummy/app/controllers/errors_controller.rb index 24672f3..1f3a74f 100644 --- a/spec/dummy/app/controllers/errors_controller.rb +++ b/spec/dummy/app/controllers/errors_controller.rb @@ -1,5 +1,5 @@ class ErrorsController < ActionController::Base def not_found - render nothing: true, status: 404 + head :not_found end end diff --git a/spec/routing_spec.rb b/spec/routing_spec.rb index 985940c..a91f0d8 100644 --- a/spec/routing_spec.rb +++ b/spec/routing_spec.rb @@ -5,46 +5,46 @@ describe "V1" do it "should not route something from V2" do - get new_api_foo_path, nil, 'HTTP_ACCEPT' => 'application/vnd.myvendor+json;version=1' + get new_api_foo_path, headers: { 'HTTP_ACCEPT' => 'application/vnd.myvendor+json;version=1' } response.status.should == 404 end it "should route" do - get new_api_bar_path, nil, 'HTTP_ACCEPT' => 'application/vnd.myvendor+json;version=1' + get new_api_bar_path, headers: { 'HTTP_ACCEPT' => 'application/vnd.myvendor+json;version=1' } @controller.class.should == Api::V1::BarController end it "should default" do - get new_api_bar_path, nil, 'HTTP_ACCEPT' => 'application/vnd.myvendor+json' + get new_api_bar_path, headers: { 'HTTP_ACCEPT' => 'application/vnd.myvendor+json' } @controller.class.should == Api::V1::BarController end it "should default with nothing after the semi-colon" do - get new_api_bar_path, nil, 'HTTP_ACCEPT' => 'application/vnd.myvendor+json; ' + get new_api_bar_path, headers: { 'HTTP_ACCEPT' => 'application/vnd.myvendor+json; ' } @controller.class.should == Api::V1::BarController end end describe "V2" do it "should copy bar" do - get new_api_bar_path, nil, 'HTTP_ACCEPT' => 'application/vnd.myvendor+json;version=2' + get new_api_bar_path, headers: { 'HTTP_ACCEPT' => 'application/vnd.myvendor+json;version=2' } @controller.class.should == Api::V2::BarController end it "should add foo" do - get new_api_foo_path, nil, 'HTTP_ACCEPT' => 'application/vnd.myvendor+json;version=2' + get new_api_foo_path, headers: { 'HTTP_ACCEPT' => 'application/vnd.myvendor+json;version=2' } @controller.class.should == Api::V2::FooController end it "should not default" do - get new_api_foo_path, nil, 'HTTP_ACCEPT' => 'application/vnd.myvendor+json' + get new_api_foo_path, headers: { 'HTTP_ACCEPT' => 'application/vnd.myvendor+json' } response.status.should == 404 end it "should default" do original_version = ApiVersions::VersionCheck.default_version ApiVersions::VersionCheck.default_version = 2 - get new_api_foo_path, nil, 'HTTP_ACCEPT' => 'application/vnd.myvendor+json' + get new_api_foo_path, headers: { 'HTTP_ACCEPT' => 'application/vnd.myvendor+json' } ApiVersions::VersionCheck.default_version = original_version @controller.class.should == Api::V2::FooController end @@ -52,12 +52,12 @@ describe "V3" do it "should copy foo" do - get new_api_foo_path, nil, 'HTTP_ACCEPT' => 'application/vnd.myvendor+json;version=3' + get new_api_foo_path, headers: { 'HTTP_ACCEPT' => 'application/vnd.myvendor+json;version=3' } @controller.class.should == Api::V3::FooController end it "should route to nested controllers" do - get new_api_nests_nested_path, nil, 'HTTP_ACCEPT' => 'application/vnd.myvendor+json;version=3' + get new_api_nests_nested_path, headers: { 'HTTP_ACCEPT' => 'application/vnd.myvendor+json;version=3' } @controller.class.should == Api::V3::Nests::NestedController end end @@ -65,7 +65,7 @@ describe "Header syntax" do context "when valid" do after(:each) do - get new_api_bar_path, nil, 'HTTP_ACCEPT' => @accept_string + get new_api_bar_path, headers: { 'HTTP_ACCEPT' => @accept_string } desired_format = /application\/.*\+\s*(?\w+)\s*/.match(@accept_string)[:format] response.content_type.should == "application/#{desired_format}" response.should be_success @@ -115,7 +115,7 @@ end it "should not route when invalid" do - get new_api_bar_path, nil, 'HTTP_ACCEPT' => 'application/vnd.garbage+xml;version=1' + get new_api_bar_path, headers: { 'HTTP_ACCEPT' => 'application/vnd.garbage+xml;version=1' } response.status.should == 404 end end