diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-26 18:10:39 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-26 18:10:39 +0300 |
commit | 8ddce74d754820b443f46cc80cddba780d740019 (patch) | |
tree | d08ae89749ba5b42ae64dd9aeeffa0228e47bc72 /spec/lib | |
parent | f2cdd73a23b94c5f6eb2f38b22a6e5bef9c52d10 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/auth/o_auth/user_spec.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/lib/gitlab/auth/o_auth/user_spec.rb b/spec/lib/gitlab/auth/o_auth/user_spec.rb index 6c6cee9c273..7a8e6e77d52 100644 --- a/spec/lib/gitlab/auth/o_auth/user_spec.rb +++ b/spec/lib/gitlab/auth/o_auth/user_spec.rb @@ -995,6 +995,23 @@ RSpec.describe Gitlab::Auth::OAuth::User do end end + context 'when gl_user is nil' do + # We can't use `allow_next_instance_of` here because the stubbed method is called inside `initialize`. + # When the class calls `gl_user` during `initialize`, the `nil` value is overwritten and we do not see expected results from the spec. + # So we use `allow_any_instance_of` to preserve the `nil` value to test the behavior when `gl_user` is nil. + + # rubocop:disable RSpec/AnyInstanceOf + before do + allow_any_instance_of(described_class).to receive(:gl_user) { nil } + allow_any_instance_of(described_class).to receive(:sync_profile_from_provider?) { true } # to make the code flow proceed until gl_user.build_user_synced_attributes_metadata is called + end + # rubocop:enable RSpec/AnyInstanceOf + + it 'does not raise NoMethodError' do + expect { oauth_user }.not_to raise_error + end + end + describe '._uid_and_provider' do let!(:existing_user) { create(:omniauth_user, extern_uid: 'my-uid', provider: 'my-provider') } |