Skip to content

Commit c55a9c7

Browse files
committed
Added failing spec for nested rescue_from declarations
1 parent 8e0b232 commit c55a9c7

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* [#1976](https://github.com/ruby-grape/grape/pull/1976): Ensure classes/modules listed for autoload really exist - [@dnesteryuk](https://github.com/dnesteryuk).
1111
* [#1971](https://github.com/ruby-grape/grape/pull/1971): Fix BigDecimal coercion - [@FlickStuart](https://github.com/FlickStuart).
1212
* [#1968](https://github.com/ruby-grape/grape/pull/1968): Fix args forwarding in Grape::Middleware::Stack#merge_with for ruby 2.7.0 - [@dm1try](https://github.com/dm1try).
13+
* [#1982](https://github.com/ruby-grape/grape/pull/1982): Added failing spec for nested rescue_from declarations - [@wowinter13](https://github.com/wowinter13).
1314

1415
### 1.3.0 (2020/01/11)
1516

Diff for: spec/grape/api/nested_rescue_from_spec.rb

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# frozen_string_literal: true
2+
3+
# see https://github.com/ruby-grape/grape/issues/1975
4+
5+
require 'spec_helper'
6+
7+
module NestedRescueFromSpec
8+
class Alpacas < Grape::API
9+
resource :alpacas do
10+
rescue_from :all do
11+
error_response(status: 200)
12+
end
13+
14+
get do
15+
{ count_alpacas: 1 / 0 }
16+
end
17+
end
18+
end
19+
20+
class Main < Grape::API
21+
rescue_from ZeroDivisionError do
22+
error_response(status: 500)
23+
end
24+
25+
mount NestedRescueFromSpec::Alpacas
26+
end
27+
end
28+
29+
describe Grape::API do
30+
subject { NestedRescueFromSpec::Main }
31+
32+
def app
33+
subject
34+
end
35+
36+
it 'calls the inner rescue_from :all from Alpacas class' do
37+
get '/alpacas'
38+
expect(last_response.status).to eql 200
39+
end
40+
end

0 commit comments

Comments
 (0)