diff options
author | Robin Bobbitt <ryehle@us.ibm.com> | 2017-06-06 11:39:54 -0400 |
---|---|---|
committer | Robin Bobbitt <ryehle@us.ibm.com> | 2017-06-07 11:13:57 -0400 |
commit | 469acd190e497cda8516da0ee481f33e038d7e9e (patch) | |
tree | 7b2fd577757c49570fc353a02a23533a0674d8fa /spec/helpers | |
parent | 8fdba5fac2a5fb4ce17a11580e94a85257e76e2c (diff) | |
download | gitlab-ce-469acd190e497cda8516da0ee481f33e038d7e9e.tar.gz |
Sync email address from specified omniauth provider
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/profiles_helper_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/helpers/profiles_helper_spec.rb b/spec/helpers/profiles_helper_spec.rb new file mode 100644 index 00000000000..b33b3f3a228 --- /dev/null +++ b/spec/helpers/profiles_helper_spec.rb @@ -0,0 +1,36 @@ +require 'rails_helper' + +describe ProfilesHelper do + describe '#email_provider_label' do + it "returns nil for users without external email" do + user = create(:user) + allow(helper).to receive(:current_user).and_return(user) + + expect(helper.email_provider_label).to be_nil + end + + it "returns omniauth provider label for users with external email" do + stub_cas_omniauth_provider + cas_user = create(:omniauth_user, provider: 'cas3', external_email: true, email_provider: 'cas3') + allow(helper).to receive(:current_user).and_return(cas_user) + + expect(helper.email_provider_label).to eq('CAS') + end + + it "returns 'LDAP' for users with external email but no email provider" do + ldap_user = create(:omniauth_user, external_email: true) + allow(helper).to receive(:current_user).and_return(ldap_user) + + expect(helper.email_provider_label).to eq('LDAP') + end + end + + def stub_cas_omniauth_provider + provider = OpenStruct.new( + 'name' => 'cas3', + 'label' => 'CAS' + ) + + stub_omniauth_setting(providers: [provider]) + end +end |