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
from
Commits
Jump to file or symbol
Failed to load files and symbols.
+55 −31
Diff settings

Always

Just for now

View
@@ -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:
View
@@ -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
View
@@ -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.