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

Added support for Rails 5.0, 5.1 and 5.2 #143

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
17c4c2e
Remove hideactions
Jan 20, 2016
3a547b2
Remove rackdelegation
Jan 20, 2016
c386e47
Updated path
Jan 21, 2016
d2444f0
Change respond type to Mime[:json]
Jan 25, 2016
abb38b1
Use String.bytesize instead
Feb 26, 2016
ac04138
Removed deprecated methods
Feb 26, 2016
e37a48f
Added back default-version
Feb 26, 2016
54015c6
Added back default-version
Feb 26, 2016
08e74df
Use before_action instead
Feb 26, 2016
a879337
Fixed versions
Jul 5, 2016
6c7e66b
Remove process in test_helper
Mar 23, 2017
8ca13a1
Only remove magical add of version
Mar 23, 2017
ab598be
Put back version
Mar 23, 2017
afdba5a
Fixed tests on Rails 5
Apr 6, 2017
4e35acb
Updated hashie dependency
May 29, 2017
0a2011e
Support for rails 5.1.0
MatayoshiMariano Aug 4, 2017
2f21e06
fixup! Support for rails 5.1.0
MatayoshiMariano Aug 4, 2017
8a69c37
fixup! Support for rails 5.1.0
MatayoshiMariano Aug 4, 2017
c45753f
Merge pull request #1 from MatayoshiMariano/support-rails-5.1.0
parse Aug 4, 2017
17aac59
Add support for Bugsnag version 6
Zhong-z Mar 10, 2018
f4be7c7
:white_check_mark: Update spec to use Bugsnag class method
Zhong-z Mar 11, 2018
d3868f9
:art: explicitly use old rspec gem
Zhong-z Mar 11, 2018
0bb2fd0
update rspec version
Zhong-z Mar 11, 2018
1cd446c
Revert "update rspec version"
Zhong-z Mar 11, 2018
82d76fa
Revert ":art: explicitly use old rspec gem"
Zhong-z Mar 11, 2018
e525768
Merge pull request #2 from Zhong-z/master
parse Apr 16, 2018
9364c2f
Added Rails version to testing
parse Apr 17, 2018
e2ac0bf
Bump Ruby versions
parse Apr 17, 2018
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -5,6 +5,9 @@ rvm:
- "2.0"
- "2.1"
- "2.2"
- "2.3"
- "2.4"
- "2.5"
env:
- RAILS_VERSION=""
- RAILS_VERSION="~>3.2.0"
@@ -13,6 +16,9 @@ env:
- RAILS_VERSION="~>4.0.0"
- RAILS_VERSION="~>4.1.0"
- RAILS_VERSION="~>4.2.0"
- RAILS_VERSION="~>5.0.0"
- RAILS_VERSION="~>5.1.0"
- RAILS_VERSION="~>5.2.0"
- RAILS_VERSION="" MONETA_VERSION="~> 0.6.0"
- RAILS_VERSION="" MONETA_VERSION="~> 0.7.0"
notifications:
@@ -15,11 +15,9 @@ class Base < ActionController::Metal
end

MODULES = [
ActionController::HideActions,
ActionController::UrlFor,
ActionController::Redirecting,
ActionController::ConditionalGet,
ActionController::RackDelegation,
record_identifier_klass,
ActionController::HttpAuthentication::Basic::ControllerMethods,
ActionController::HttpAuthentication::Digest::ControllerMethods,
@@ -3,7 +3,7 @@ module FormatVerification
extend ActiveSupport::Concern

included do
before_filter :ensure_has_valid_format
before_action :ensure_has_valid_format
end

private
@@ -13,4 +13,4 @@ def ensure_has_valid_format
end

end
end
end
@@ -43,8 +43,8 @@ def wrap_response_in_jsonp
# Finally, set up the callback using the JSONP parameter.
response.content_type = 'application/javascript'
response.body = "#{jsonp_parameter}(#{response.body});"
headers['Content-Length'] = Rack::Utils.bytesize(response.body).to_s
headers['Content-Length'] = (response.body.bytesize).to_s
end

end
end
end
@@ -23,7 +23,13 @@ module Rescuable
end
},
:bugsnag => lambda { |controller, exception, request|
controller.send(:notify_bugsnag, exception, request: request)
if controller.respond_to?(:notify_bugsnag, true)
controller.send(:notify_bugsnag, exception, request: request)
else
# Bugsnag v6 removed #notify_bugsnag controller method
# Use #notify directly
Bugsnag.notify(exception)
end
}
}

@@ -123,9 +123,9 @@ def render_json(json, options = {})
json = encode_to_json(json) unless json.respond_to?(:to_str)
# Encode the object to json.
self.status ||= :ok
self.content_type ||= Mime::JSON
self.content_type ||= Mime[:json]
self.response_body = json
headers['Content-Length'] = Rack::Utils.bytesize(json).to_s
headers['Content-Length'] = (json.bytesize).to_s
end

# Renders a raw object, without any wrapping etc.
@@ -227,4 +227,4 @@ def metadata_for(object, options, type, singular)
end

end
end
end
@@ -12,7 +12,7 @@ module ClassMethods
def version(version)
version = version..version if version.is_a?(Integer)
self._version_range = version
before_filter :verify_api_version
before_action :verify_api_version
end

end
@@ -7,7 +7,7 @@ class Railtie < Rails::Railtie
config.rocket_pants.pass_through_errors = nil
config.rocket_pants.pass_through_errors = nil

config.i18n.railties_load_path << File.expand_path('../locale/en.yml', __FILE__)
config.i18n.load_path << File.expand_path('../locale/en.yml', __FILE__)

initializer "rocket_pants.logger" do
ActiveSupport.on_load(:rocket_pants) { self.logger ||= Rails.logger }
@@ -39,7 +39,12 @@ class Railtie < Rails::Railtie

initializer "rocket_pants.setup_caching" do |app|
if RocketPants.caching_enabled?
app.middleware.insert 'Rack::Runtime', RocketPants::CacheMiddleware
run_time_middleware = if Rails::VERSION::MAJOR >= 5
Rack::Runtime
else
"Rack::Runtime"
end
app.middleware.insert run_time_middleware, RocketPants::CacheMiddleware
end
end

@@ -54,4 +59,4 @@ class Railtie < Rails::Railtie
end

end
end
end
@@ -9,9 +9,6 @@ module TestHelper

# Extend the response on first include.
class_attribute :_default_version
unless ActionController::TestResponse < ResponseHelper
ActionController::TestResponse.send :include, ResponseHelper
end

unless ActionDispatch::TestResponse < ResponseHelper
ActionDispatch::TestResponse.send :include, ResponseHelper
@@ -90,21 +87,30 @@ def insert_action_controller_testing_into_base

# Like process, but automatically adds the api version.
def process(action, *args)

insert_action_controller_testing_into_base

# Rails 4 changes the method signature. In rails 3, parameters is the first argument.
# In Rails 4, it's the second.
if args.first.is_a?(String)
parameters = (args[1] ||= {})
if Rails::VERSION::MAJOR <= 4
# Rails 4 changes the method signature. In rails 3, parameters is the first argument.
# In Rails 4, it's the second.
if args.first.is_a?(String)
parameters = (args[1] ||= {})
else
parameters = (args[0] ||= {})
end
else
parameters = (args[0] ||= {})
end

response.recycle_cached_body!

if _default_version.present? && parameters[:version].blank? && parameters['version'].blank?
parameters[:version] = _default_version
if Rails::VERSION::MAJOR <= 4
if _default_version.present? && parameters[:version].blank? && parameters['version'].blank?
parameters[:version] = _default_version
end
else
if _default_version.present? && parameters[:params][:version].blank?
parameters[:params][:version] = _default_version
end
end

super action, *args
@@ -13,21 +13,21 @@ Gem::Specification.new do |s|
s.description = "Rocket Pants adds JSON API love to Rails and ActionController, making it simpler to build API-oriented controllers."
s.required_rubygems_version = ">= 1.3.6"

s.add_dependency 'actionpack', '>= 3.0', '< 5.0'
s.add_dependency 'railties', '>= 3.0', '< 5.0'
s.add_dependency 'actionpack', '>= 3.0', '< 6.0'
s.add_dependency 'railties', '>= 3.0', '< 6.0'
s.add_dependency 'will_paginate', '~> 3.0'
s.add_dependency 'hashie', '>= 1.0', '< 3'
s.add_dependency 'hashie', '>= 1.0', '< 4'
s.add_dependency 'api_smith'
s.add_dependency 'moneta'
s.add_development_dependency 'rspec', '>= 2.4', '< 4.0'
s.add_development_dependency 'rspec-rails', '>= 2.4', '< 4.0'
s.add_development_dependency 'rr', '~> 1.0'
s.add_development_dependency 'webmock'
s.add_development_dependency 'activerecord', '>= 3.0', '< 5.0'
s.add_development_dependency 'activerecord', '>= 3.0', '< 6.0'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'reversible_data', '~> 1.0'
s.add_development_dependency 'kaminari'

s.files = Dir.glob("{lib}/**/*")
s.require_path = 'lib'
end
end
@@ -75,6 +75,9 @@
before :each do
controller_class.use_named_exception_notifier :bugsnag
stub.instance_of(controller_class).notify_bugsnag {}
Bugsnag = Class.new do
define_singleton_method(:notify) { |exception| }
end
end

it 'should send notification when it is the named exception notifier' do
@@ -410,7 +410,7 @@ def object.serializable_hash(*); {:serialised => true}; end
get :echo, :echo => "Hello World", :callback => "test"
response.content_type.should include 'application/javascript'
response.body.should == %|test({"response":{"echo":"Hello World"}});|
response.headers['Content-Length'].to_i.should == Rack::Utils.bytesize(response.body)
response.headers['Content-Length'].to_i.should == response.body.bytesize
end

end
@@ -436,4 +436,4 @@ def object.serializable_hash(*); {:serialised => true}; end

end

end
end
ProTip! Use n and p to navigate between commits in a pull request.