diff --git a/CHANGELOG.md b/CHANGELOG.md index e4df3db3fc..0e50c5cab4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * [#1976](https://github.com/ruby-grape/grape/pull/1976): Ensure classes/modules listed for autoload really exist - [@dnesteryuk](https://github.com/dnesteryuk). * [#1971](https://github.com/ruby-grape/grape/pull/1971): Fix BigDecimal coercion - [@FlickStuart](https://github.com/FlickStuart). * [#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). +* [#1982](https://github.com/ruby-grape/grape/pull/1982): Added failing spec for nested rescue_from declarations - [@wowinter13](https://github.com/wowinter13). ### 1.3.0 (2020/01/11) diff --git a/spec/grape/api/nested_rescue_from_spec.rb b/spec/grape/api/nested_rescue_from_spec.rb new file mode 100644 index 0000000000..e94c1fe2b5 --- /dev/null +++ b/spec/grape/api/nested_rescue_from_spec.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +# see https://github.com/ruby-grape/grape/issues/1975 + +require 'spec_helper' + +module NestedRescueFromSpec + class Alpacas < Grape::API + resource :alpacas do + rescue_from :all do + error_response(status: 200) + end + + get do + { count_alpacas: 1 / 0 } + end + end + end + + class Main < Grape::API + rescue_from ZeroDivisionError do + error_response(status: 500) + end + + mount NestedRescueFromSpec::Alpacas + end +end + +describe Grape::API do + subject { NestedRescueFromSpec::Main } + + def app + subject + end + + it 'calls the inner rescue_from :all from Alpacas class' do + get '/alpacas' + expect(last_response.status).to eql 200 + end +end