Skip validation when creating internal (ghost, service desk) users

This commit is contained in:
Douwe Maan 2017-04-26 14:13:04 -05:00
parent d39b16d06d
commit b9e573db57
3 changed files with 17 additions and 1 deletions

View file

@ -1068,11 +1068,13 @@ class User < ActiveRecord::Base
User.find_by_email(s)
end
scope.create(
user = scope.build(
username: username,
email: email,
&creation_block
)
user.save(validate: false)
user
ensure
Gitlab::ExclusiveLease.cancel(lease_key, uuid)
end

View file

@ -0,0 +1,4 @@
---
title: Skip validation when creating internal (ghost, service desk) users
merge_request:
author:

View file

@ -1556,6 +1556,16 @@ describe User, models: true do
expect(ghost.email).to eq('ghost1@example.com')
end
end
context 'when a domain whitelist is in place' do
before do
stub_application_setting(domain_whitelist: ['gitlab.com'])
end
it 'creates a ghost user' do
expect(User.ghost).to be_persisted
end
end
end
describe '#update_two_factor_requirement' do