Skip to content

Commit

Permalink
Fix UPGRADING.md
Browse files Browse the repository at this point in the history
Change deprecation msg
  • Loading branch information
ericproulx committed Jan 22, 2024
1 parent ac6c7a3 commit aaa5982
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion UPGRADING.md
Expand Up @@ -4,7 +4,10 @@ Upgrading Grape
### Upgrading to >= 2.1.0

#### Changes in rescue_from
`rack_response` has been deprecated and `error_response` has been removed. Use `error!` instead.

The `rack_response` method has been deprecated and the `error_response` method has been removed. Use `error!` instead.

See [#2414](https://github.com/ruby-grape/grape/pull/2414) for more information.

#### Grape::Router::Route.route_xxx methods have been removed

Expand Down
2 changes: 1 addition & 1 deletion lib/grape/dsl/inside_route.rb
Expand Up @@ -180,7 +180,7 @@ def error!(message, status = nil, additional_headers = nil)
# A Rack::Response object containing the specified message, status, and headers.
#
def rack_response(message, status = 200, headers = { Rack::CONTENT_TYPE => content_type })
Grape.deprecator.warn('Use error! instead of rack_response')
Grape.deprecator.warn('The rack_response method has been deprecated, use error! instead.')
message = Rack::Utils.escape_html(message) if headers[Rack::CONTENT_TYPE] == 'text/html'
Rack::Response.new(Array.wrap(message), Rack::Utils.status_code(status), headers)
end
Expand Down
3 changes: 2 additions & 1 deletion spec/grape/api_spec.rb
Expand Up @@ -4437,8 +4437,9 @@ def uniqe_id_route
end

it 'raises a deprecation' do
expect(Grape.deprecator).to receive(:warn).with('Use error! instead of rack_response')
expect(Grape.deprecator).to receive(:warn).with('The rack_response method has been deprecated, use error! instead.')
get 'test'
expect(last_response.body).to eq('deprecated')
end
end
end

0 comments on commit aaa5982

Please sign in to comment.