Commit dc41ba4f authored by Dmytro Zaporozhets's avatar Dmytro Zaporozhets

Merge branch 'fix-routes-for-internal-users' into 'master'

Resolve "Routes are not being generated on creation of internal bot users (support-bot, alert-bot etc)

See merge request gitlab-org/gitlab!35711
parents 1dfbbbaf 7f07b770
......@@ -17,11 +17,8 @@ module Routable
after_validation :set_path_errors
before_validation do
if full_path_changed? || full_name_changed?
prepare_route
end
end
before_validation :prepare_route
before_save :prepare_route # in case validation is skipped
end
class_methods do
......@@ -118,6 +115,8 @@ module Routable
end
def prepare_route
return unless full_path_changed? || full_name_changed?
route || build_route(source: self)
route.path = build_full_path
route.name = build_full_name
......
---
title: Create associated routes when a new bot user is created
merge_request: 35711
author:
type: fixed
......@@ -4766,6 +4766,12 @@ RSpec.describe User do
end.to change { User.where(user_type: bot_type).count }.by(1)
end
it 'creates a route for the namespace of the created user' do
bot_user = described_class.public_send(bot_type)
expect(bot_user.namespace.route).to be_present
end
it 'does not create a new user if it already exists' do
described_class.public_send(bot_type)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment