summaryrefslogtreecommitdiff
path: root/spec/controllers/profiles_controller_spec.rb
diff options
context:
space:
mode:
authorAlexander Keramidas <dev.alexkeramidas@gmail.com>2017-08-29 11:57:41 +0300
committerAlexander Keramidas <dev.alexkeramidas@gmail.com>2017-09-06 16:38:52 +0300
commit4df54f260751a832ebf0b8c18524020d6604994b (patch)
tree2337fd9cc3fe1a1c82d9cc980dcce22465e493ce /spec/controllers/profiles_controller_spec.rb
parent021fb512e3c3f4b317307358dee8eecf448599b0 (diff)
downloadgitlab-ce-4df54f260751a832ebf0b8c18524020d6604994b.tar.gz
Profile updates from providers
Diffstat (limited to 'spec/controllers/profiles_controller_spec.rb')
-rw-r--r--spec/controllers/profiles_controller_spec.rb25
1 files changed, 24 insertions, 1 deletions
diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb
index 9d60dab12d1..b52b63e05a4 100644
--- a/spec/controllers/profiles_controller_spec.rb
+++ b/spec/controllers/profiles_controller_spec.rb
@@ -16,7 +16,11 @@ describe ProfilesController do
end
it "ignores an email update from a user with an external email address" do
- ldap_user = create(:omniauth_user, external_email: true)
+ stub_omniauth_setting(sync_profile_from_provider: ['ldap'])
+ stub_omniauth_setting(sync_profile_attributes: true)
+
+ ldap_user = create(:omniauth_user)
+ ldap_user.create_user_synced_attributes_metadata(provider: 'ldap', name_synced: true, email_synced: true)
sign_in(ldap_user)
put :update,
@@ -27,5 +31,24 @@ describe ProfilesController do
expect(response.status).to eq(302)
expect(ldap_user.unconfirmed_email).not_to eq('john@gmail.com')
end
+
+ it "ignores an email and name update but allows a location update from a user with external email and name, but not external location" do
+ stub_omniauth_setting(sync_profile_from_provider: ['ldap'])
+ stub_omniauth_setting(sync_profile_attributes: true)
+
+ ldap_user = create(:omniauth_user, name: 'Alex')
+ ldap_user.create_user_synced_attributes_metadata(provider: 'ldap', name_synced: true, email_synced: true, location_synced: false)
+ sign_in(ldap_user)
+
+ put :update,
+ user: { email: "john@gmail.com", name: "John", location: "City, Country" }
+
+ ldap_user.reload
+
+ expect(response.status).to eq(302)
+ expect(ldap_user.unconfirmed_email).not_to eq('john@gmail.com')
+ expect(ldap_user.name).not_to eq('John')
+ expect(ldap_user.location).to eq('City, Country')
+ end
end
end