diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /spec/controllers/google_api | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/controllers/google_api')
-rw-r--r-- | spec/controllers/google_api/authorizations_controller_spec.rb | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/spec/controllers/google_api/authorizations_controller_spec.rb b/spec/controllers/google_api/authorizations_controller_spec.rb index 58bda2bd4e8..9d0e0d92978 100644 --- a/spec/controllers/google_api/authorizations_controller_spec.rb +++ b/spec/controllers/google_api/authorizations_controller_spec.rb @@ -12,10 +12,6 @@ describe GoogleApi::AuthorizationsController do before do sign_in(user) - - allow_next_instance_of(GoogleApi::CloudPlatform::Client) do |instance| - allow(instance).to receive(:get_token).and_return([token, expires_at]) - end end shared_examples_for 'access denied' do @@ -38,6 +34,12 @@ describe GoogleApi::AuthorizationsController do context 'session key matches state param' do let(:state) { session_key } + before do + allow_next_instance_of(GoogleApi::CloudPlatform::Client) do |instance| + allow(instance).to receive(:get_token).and_return([token, expires_at]) + end + end + it 'sets token and expires_at in session' do subject @@ -63,6 +65,22 @@ describe GoogleApi::AuthorizationsController do it_behaves_like 'access denied' end + + context 'when a Faraday exception occurs' do + let(:state) { session_key } + + [::Faraday::TimeoutError, ::Faraday::ConnectionFailed].each do |error| + it "sets a flash alert on #{error}" do + allow_next_instance_of(GoogleApi::CloudPlatform::Client) do |instance| + allow(instance).to receive(:get_token).and_raise(error.new(nil)) + end + + subject + + expect(flash[:alert]).to eq('Timeout connecting to the Google API. Please try again.') + end + end + end end context 'state param is present, but session key is blank' do |