Rewrite oauth application owner to deleted user

[OP#42311](https://community.openproject.org/wp/42311)
pull/10659/head
Oliver Günther 3 years ago
parent 178c22c915
commit bee887aea7
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 7
      app/services/principals/replace_references_service.rb
  2. 17
      spec/services/principals/replace_references_service_call_integration_spec.rb

@ -48,6 +48,7 @@ module Principals
rewrite_assigned_to(from, to)
rewrite_responsible(from, to)
rewrite_actor(from, to)
rewrite_owner(from, to)
end
def rewrite_custom_value(from, to)
@ -107,6 +108,12 @@ module Principals
end
end
def rewrite_owner(from, to)
[::Doorkeeper::Application].each do |klass|
klass.where(owner_id: from.id).update_all(owner_id: to.id)
end
end
def rewrite_assigned_to(from, to)
[WorkPackage].each do |klass|
klass.where(assigned_to_id: from.id).update_all(assigned_to_id: to.id)

@ -419,5 +419,22 @@ describe Principals::ReplaceReferencesService, '#call', type: :model do
end
end
end
context 'with OAuth application' do
it_behaves_like 'rewritten record',
:oauth_application,
:owner_id do
let(:attributes) do
{
name: "'foo'",
uid: "'bar'",
secret: "'bar'",
redirect_uri: "'urn:whatever'",
created_at: 'NOW()',
updated_at: 'NOW()'
}
end
end
end
end
end

Loading…
Cancel
Save