Commit 11a60096 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'upgrade-grape' into 'master'

Update Grape from 0.13.0 to 0.15.0

Changelog: https://github.com/ruby-grape/grape/blob/v0.15.0/CHANGELOG.md

Working on #18226.

See merge request !4601
parents b8130d42 da29a55d
......@@ -33,6 +33,7 @@ v 8.11.0 (unreleased)
- Remove delay when hitting "Reply..." button on page with a lot of discussions
- Retrieve rendered HTML from cache in one request
- Fix renaming repository when name contains invalid chararacters under project settings
- Upgrade Grape from 0.13.0 to 0.15.0. !4601
- Fix devise deprecation warnings.
- Update version_sorter and use new interface for faster tag sorting
- Optimize checking if a user has read access to a list of issues !5370
......
......@@ -69,7 +69,7 @@ gem 'gollum-rugged_adapter', '~> 0.4.2', require: false
gem 'github-linguist', '~> 4.7.0', require: 'linguist'
# API
gem 'grape', '~> 0.13.0'
gem 'grape', '~> 0.15.0'
gem 'grape-entity', '~> 0.4.2'
gem 'rack-cors', '~> 0.4.0', require: 'rack/cors'
......
......@@ -308,7 +308,7 @@ GEM
json
multi_json
request_store (>= 1.0)
grape (0.13.0)
grape (0.15.0)
activesupport
builder
hashie (>= 2.1.0)
......@@ -876,7 +876,7 @@ DEPENDENCIES
gollum-lib (~> 4.2)
gollum-rugged_adapter (~> 0.4.2)
gon (~> 6.1.0)
grape (~> 0.13.0)
grape (~> 0.15.0)
grape-entity (~> 0.4.2)
hamlit (~> 2.5)
health_check (~> 2.1.0)
......
......@@ -7,8 +7,10 @@ module API
rack_response({ 'message' => '404 Not found' }.to_json, 404)
end
rescue_from Grape::Exceptions::ValidationErrors do |e|
error!({ messages: e.full_messages }, 400)
# Retain 405 error rather than a 500 error for Grape 0.15.0+.
# See: https://github.com/ruby-grape/grape/commit/252bfd27c320466ec3c0751812cf44245e97e5de
rescue_from Grape::Exceptions::Base do |e|
error! e.message, e.status, e.headers
end
rescue_from :all do |exception|
......
......@@ -398,9 +398,9 @@ describe API::API, api: true do
end.to change{ user.keys.count }.by(1)
end
it "returns 405 for invalid ID" do
post api("/users/ASDF/keys", admin)
expect(response).to have_http_status(405)
it "returns 400 for invalid ID" do
post api("/users/999999/keys", admin)
expect(response).to have_http_status(400)
end
end
......@@ -429,11 +429,6 @@ describe API::API, api: true do
expect(json_response).to be_an Array
expect(json_response.first['title']).to eq(key.title)
end
it "returns 405 for invalid ID" do
get api("/users/ASDF/keys", admin)
expect(response).to have_http_status(405)
end
end
end
......@@ -490,8 +485,8 @@ describe API::API, api: true do
end
it "raises error for invalid ID" do
post api("/users/ASDF/emails", admin)
expect(response).to have_http_status(405)
post api("/users/999999/emails", admin)
expect(response).to have_http_status(400)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment