Skip to content

Commit

Permalink
Re-added Grape::API::Helpers for backward compatibility, broken in #716.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Aug 24, 2014
1 parent 1db4c5e commit 3411432
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/grape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ module DSL
autoload :Routing, 'grape/dsl/routing'
autoload :Validations, 'grape/dsl/validations'
end

class API
autoload :Helpers, 'grape/api/helpers'
end
end

require 'grape/version'
7 changes: 7 additions & 0 deletions lib/grape/api/helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Grape
class API
module Helpers
include Grape::DSL::Helpers::BaseHelper
end
end
end
36 changes: 36 additions & 0 deletions spec/grape/api/helpers_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require 'spec_helper'

describe Grape::API::Helpers do
module SharedParams
extend Grape::API::Helpers

params :pagination do
optional :page, type: Integer
optional :size, type: Integer
end
end

subject do
Class.new(Grape::API) do
helpers SharedParams
format :json

params do
use :pagination
end
get do
declared(params, include_missing: true)
end
end
end

def app
subject
end

it 'defines parameters' do
get '/'
expect(last_response.status).to eq 200
expect(last_response.body).to eq({ page: nil, size: nil }.to_json)
end
end

0 comments on commit 3411432

Please sign in to comment.