-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-added Grape::API::Helpers for backward compatibility, broken in #716.
- Loading branch information
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |