Fix snapshot creator at locking task [SCI-11515]

This commit is contained in:
Andrej 2025-02-10 10:40:48 +01:00
parent f30844be6d
commit 14a0aef43a
4 changed files with 7 additions and 5 deletions

View file

@ -373,6 +373,8 @@ class MyModulesController < ApplicationController
def update_state
old_status_id = @my_module.my_module_status_id
@my_module.my_module_status_created_by = current_user
if @my_module.update(my_module_status_id: update_status_params[:status_id])
log_activity(:change_status_on_task_flow, @my_module, my_module_status_old: old_status_id,
my_module_status_new: @my_module.my_module_status.id)

View file

@ -14,7 +14,7 @@ class MyModule < ApplicationRecord
include Assignable
include Cloneable
attr_accessor :transition_error_rollback
attr_accessor :transition_error_rollback, :my_module_status_created_by
enum state: Extends::TASKS_STATES
enum provisioning_status: { done: 0, in_progress: 1, failed: 2 }
@ -567,7 +567,7 @@ class MyModule < ApplicationRecord
if status_changing_direction == :forward
my_module_status.my_module_status_consequences.each do |consequence|
consequence.before_forward_call(self)
consequence.before_forward_call(self, my_module_status_created_by)
end
end

View file

@ -7,7 +7,7 @@ class MyModuleStatusConsequence < ApplicationRecord
def backward(my_module); end
def before_forward_call(my_module); end
def before_forward_call(my_module, user = nil); end
def runs_in_background?
false

View file

@ -6,9 +6,9 @@ module MyModuleStatusConsequences
true
end
def before_forward_call(my_module)
def before_forward_call(my_module, created_by = nil)
my_module.assigned_repositories.each do |repository|
::RepositorySnapshot.create_preliminary!(repository, my_module)
::RepositorySnapshot.create_preliminary!(repository, my_module, created_by)
end
end