Skip to content

Commit

Permalink
Update dependencies and make it compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
nashby committed Jul 7, 2018
1 parent f55068f commit d91fb48
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 47 deletions.
22 changes: 9 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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:
- [email protected]
- [email protected]
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
15 changes: 1 addition & 14 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
6 changes: 6 additions & 0 deletions Gemfile.rails50
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source "http://rubygems.org"

# Specify your gem's dependencies in api-versions.gemspec
gemspec

gem 'rails', '~> 5.0'
6 changes: 6 additions & 0 deletions Gemfile.rails51
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source "http://rubygems.org"

# Specify your gem's dependencies in api-versions.gemspec
gemspec

gem 'rails', '~> 5.1'
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions api-versions.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion spec/dummy/app/controllers/api/v1/bar_controller.rb
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion spec/dummy/app/controllers/api/v2/foo_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Api::V3::Nests::NestedController < ActionController::Base
def new
render nothing: true
render body: nil
end
end
2 changes: 1 addition & 1 deletion spec/dummy/app/controllers/errors_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ErrorsController < ActionController::Base
def not_found
render nothing: true, status: 404
head :not_found
end
end
24 changes: 12 additions & 12 deletions spec/routing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,67 +5,67 @@

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
end

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

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*(?<format>\w+)\s*/.match(@accept_string)[:format]
response.content_type.should == "application/#{desired_format}"
response.should be_success
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d91fb48

Please sign in to comment.