diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-01-19 18:25:38 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-01-19 18:25:38 +0300 |
commit | 98e1a5b63424b6912de98ee5055d3f9e57e63899 (patch) | |
tree | 773952fd630e222ec72d368f53e4a238d3d6c839 /spec/lib/gitlab/ldap | |
parent | 425f8d6f572a3ae47c971a48bfefc9907c7bda55 (diff) |
Allow LDAP users to change their email if it was not set by the LDAP server
Diffstat (limited to 'spec/lib/gitlab/ldap')
-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). |