Class: Import::SourceUsers::CancelReassignmentService
- Inherits:
-
BaseService
- Object
- BaseService
- Import::SourceUsers::CancelReassignmentService
- Defined in:
- app/services/import/source_users/cancel_reassignment_service.rb
Instance Attribute Summary collapse
-
#reassign_to_user ⇒ Object
readonly
Returns the value of attribute reassign_to_user.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(import_source_user, current_user:) ⇒ CancelReassignmentService
constructor
A new instance of CancelReassignmentService.
Methods included from Gitlab::InternalEventsTracking
Constructor Details
#initialize(import_source_user, current_user:) ⇒ CancelReassignmentService
Returns a new instance of CancelReassignmentService.
8 9 10 11 12 |
# File 'app/services/import/source_users/cancel_reassignment_service.rb', line 8 def initialize(import_source_user, current_user:) @import_source_user = import_source_user @reassign_to_user = import_source_user.reassign_to_user @current_user = current_user end |
Instance Attribute Details
#reassign_to_user ⇒ Object (readonly)
Returns the value of attribute reassign_to_user.
6 7 8 |
# File 'app/services/import/source_users/cancel_reassignment_service.rb', line 6 def reassign_to_user @reassign_to_user end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/services/import/source_users/cancel_reassignment_service.rb', line 14 def execute return unless current_user.can?(:admin_import_source_user, import_source_user) invalid_status = false cancel_successful = false import_source_user.with_lock do if import_source_user.cancelable_status? cancel_successful = cancel_reassignment else invalid_status = true end end return error_invalid_status if invalid_status if cancel_successful track_reassignment_event( 'cancel_placeholder_user_reassignment', reassign_to_user: reassign_to_user ) ServiceResponse.success(payload: import_source_user) else ServiceResponse.error(payload: import_source_user, message: import_source_user.errors.) end end |