diff options
| author | Robert Speicher <robert@gitlab.com> | 2016-01-19 19:15:23 +0000 |
|---|---|---|
| committer | Robert Speicher <robert@gitlab.com> | 2016-01-19 19:15:23 +0000 |
| commit | b9fca47854dd92415e2d4d3b68e2e967fee2d67b (patch) | |
| tree | efb3672cf53834d5fa71d44d3ac72edf4846466f /spec | |
| parent | 20cc4bc47533f34b62b7c8283e8de4eee8c5b852 (diff) | |
| parent | 4f44455626a567c939bf6f84684e8879ce2db829 (diff) | |
| download | gitlab-ce-b9fca47854dd92415e2d4d3b68e2e967fee2d67b.tar.gz | |
Merge branch 'user-ldap-email' into 'master'
Allow LDAP users to change their email if it was not set by the LDAP
server
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/3054
See merge request !2502
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/lib/gitlab/ldap/user_spec.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/spec/lib/gitlab/ldap/user_spec.rb b/spec/lib/gitlab/ldap/user_spec.rb index 1e755259dae..03199a2523e 100644 --- a/spec/lib/gitlab/ldap/user_spec.rb +++ b/spec/lib/gitlab/ldap/user_spec.rb @@ -37,7 +37,7 @@ describe Gitlab::LDAP::User, lib: true do end it "dont marks existing ldap user as changed" do - create(:omniauth_user, email: 'john@example.com', extern_uid: 'my-uid', provider: 'ldapmain') + create(:omniauth_user, email: 'john@example.com', extern_uid: 'my-uid', provider: 'ldapmain', ldap_email: true) expect(ldap_user.changed?).to be_falsey end end @@ -110,6 +110,32 @@ describe Gitlab::LDAP::User, lib: true do end end + describe 'updating email' do + context "when LDAP sets an email" do + it "has a real email" do + expect(ldap_user.gl_user.email).to eq(info[:email]) + end + + it "has ldap_email set to true" do + expect(ldap_user.gl_user.ldap_email?).to be(true) + end + end + + context "when LDAP doesn't set an email" do + before do + info.delete(:email) + end + + it "has a temp email" do + expect(ldap_user.gl_user.temp_oauth_email?).to be(true) + end + + it "has ldap_email set to false" do + expect(ldap_user.gl_user.ldap_email?).to be(false) + end + end + end + describe 'blocking' do def configure_block(value) allow_any_instance_of(Gitlab::LDAP::Config). |
