diff --git a/lib/import/ldap/user.rb b/lib/import/ldap/user.rb index a71415aea..670108da2 100644 --- a/lib/import/ldap/user.rb +++ b/lib/import/ldap/user.rb @@ -89,7 +89,10 @@ module Import update_roles = role_ids(resource) resource[:role_ids] = update_roles if update_roles - user_found = super + user_found = false + import_class.without_callback(:update, :after, :avatar_for_email_check) do + user_found = super + end # in case a User was found and we had no roles # to set/update we have to note the currently @@ -156,12 +159,14 @@ module Import end def create(resource, *_args) - # this is needed for the special case described in the role_ids method # # in case we have no role IDs yet we have to fall back to the signup roles resource[:role_ids] ||= @signup_role_ids - super + + import_class.without_callback(:create, :after, :avatar_for_email_check) do + super + end rescue => e ldap_log( action: "create -> #{resource[:login]}", diff --git a/spec/lib/import/ldap/user_spec.rb b/spec/lib/import/ldap/user_spec.rb index f112b4ecd..e7dc10e08 100644 --- a/spec/lib/import/ldap/user_spec.rb +++ b/spec/lib/import/ldap/user_spec.rb @@ -48,6 +48,13 @@ RSpec.describe Import::Ldap::User do }.by(1) end + it "doesn't contact avatar webservice" do + # sadly we can't ensure that there are no + # outgoing HTTP calls with WebMock + expect(Avatar).not_to receive(:auto_detection) + described_class.new(user_entry, ldap_config, user_roles, signup_role_ids) + end + it 'creates an HTTP Log entry' do expect do described_class.new(user_entry, ldap_config, user_roles, signup_role_ids) @@ -124,6 +131,13 @@ RSpec.describe Import::Ldap::User do } end + it "doesn't contact avatar webservice" do + # sadly we can't ensure that there are no + # outgoing HTTP calls with WebMock + expect(Avatar).not_to receive(:auto_detection) + described_class.new(user_entry, ldap_config, user_roles, signup_role_ids) + end + it "doesn't change roles if no role mapping is configured" do expect do described_class.new(user_entry, ldap_config, {}, signup_role_ids)