-
-
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.
Merge pull request #1001 from hodak/deeply-include-format-option-issu…
…e-965 Use proper .format suffix if you have one path, issue 965
- Loading branch information
Showing
7 changed files
with
95 additions
and
9 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
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
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,56 @@ | ||
require 'spec_helper' | ||
|
||
module API | ||
module Defaults | ||
extend ActiveSupport::Concern | ||
included do | ||
format :json | ||
end | ||
end | ||
|
||
module Admin | ||
module Defaults | ||
extend ActiveSupport::Concern | ||
include API::Defaults | ||
end | ||
|
||
class Users < Grape::API | ||
include API::Admin::Defaults | ||
|
||
resource :users do | ||
get do | ||
status 200 | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
class Main < Grape::API | ||
mount API::Admin::Users | ||
end | ||
|
||
describe Grape::API do | ||
subject { Main } | ||
|
||
def app | ||
subject | ||
end | ||
|
||
it 'works for unspecified format' do | ||
get '/users' | ||
expect(last_response.status).to eql 200 | ||
expect(last_response.content_type).to eql 'application/json' | ||
end | ||
|
||
it 'works for specified format' do | ||
get '/users.json' | ||
expect(last_response.status).to eql 200 | ||
expect(last_response.content_type).to eql 'application/json' | ||
end | ||
|
||
it "doesn't work for format different than specified" do | ||
get '/users.txt' | ||
expect(last_response.status).to eql 404 | ||
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
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