diff options
Diffstat (limited to 'spec/controllers/graphql_controller_spec.rb')
-rw-r--r-- | spec/controllers/graphql_controller_spec.rb | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/spec/controllers/graphql_controller_spec.rb b/spec/controllers/graphql_controller_spec.rb index 4de31e2e135..0818dce776d 100644 --- a/spec/controllers/graphql_controller_spec.rb +++ b/spec/controllers/graphql_controller_spec.rb @@ -9,15 +9,10 @@ RSpec.describe GraphqlController do stub_feature_flags(graphql: true) end - describe 'ArgumentError' do - let(:user) { create(:user) } - let(:message) { 'green ideas sleep furiously' } + describe 'rescue_from' do + let_it_be(:message) { 'green ideas sleep furiously' } - before do - sign_in(user) - end - - it 'handles argument errors' do + it 'handles ArgumentError' do allow(subject).to receive(:execute) do raise Gitlab::Graphql::Errors::ArgumentError, message end @@ -28,6 +23,19 @@ RSpec.describe GraphqlController do 'errors' => include(a_hash_including('message' => message)) ) end + + it 'handles StandardError' do + allow(subject).to receive(:execute) do + raise StandardError, message + end + + post :execute + + expect(json_response).to include( + 'errors' => include(a_hash_including('message' => /Internal server error/, + 'raisedAt' => /graphql_controller_spec.rb/)) + ) + end end describe 'POST #execute' do |