mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-21 15:36:22 +08:00
Merge pull request #2496 from aignatov-bio/ai-sci-4471-assign-user-after-task-create
Assign user after task created [SCI-4471]
This commit is contained in:
commit
f92d68d192
|
@ -293,6 +293,8 @@ class Experiment < ApplicationRecord
|
|||
my_module.last_modified_by = current_user
|
||||
my_module.save!
|
||||
|
||||
my_module.assign_user(current_user)
|
||||
|
||||
ids_map[m[:id]] = my_module.id.to_s
|
||||
end
|
||||
my_modules.reload
|
||||
|
|
|
@ -539,6 +539,21 @@ class MyModule < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def assign_user(user, assigned_by = nil)
|
||||
user_my_modules.create(
|
||||
assigned_by: assigned_by || user,
|
||||
user: user
|
||||
)
|
||||
Activities::CreateActivityService
|
||||
.call(activity_type: :assign_user_to_module,
|
||||
owner: assigned_by || user,
|
||||
team: experiment.project.team,
|
||||
project: experiment.project,
|
||||
subject: self,
|
||||
message_items: { my_module: id,
|
||||
user_target: user.id })
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_blank_protocol
|
||||
|
|
|
@ -32,6 +32,9 @@ class CreateMyModuleService
|
|||
|
||||
@my_module.save!
|
||||
create_my_module_activity
|
||||
|
||||
@my_module.assign_user(@user)
|
||||
|
||||
@params[:experiment].generate_workflow_img
|
||||
new_my_module = @my_module
|
||||
end
|
||||
|
|
|
@ -103,7 +103,9 @@ describe Experiment, type: :model do
|
|||
expect(Activities::CreateActivityService)
|
||||
.to(receive(:call)
|
||||
.with(hash_including(activity_type: :create_module)))
|
||||
|
||||
expect(Activities::CreateActivityService)
|
||||
.to(receive(:call)
|
||||
.with(hash_including(activity_type: :assign_user_to_module)))
|
||||
function_call
|
||||
end
|
||||
|
||||
|
@ -137,12 +139,15 @@ describe Experiment, type: :model do
|
|||
.to(receive(:call)
|
||||
.with(hash_including(activity_type:
|
||||
:clone_module))).exactly(3).times
|
||||
|
||||
expect(Activities::CreateActivityService)
|
||||
.to(receive(:call)
|
||||
.with(hash_including(activity_type:
|
||||
:assign_user_to_module))).exactly(3).times
|
||||
function_call
|
||||
end
|
||||
|
||||
it 'creats 3 new activities in DB' do
|
||||
expect { function_call }.to change { Activity.all.count }.by(3)
|
||||
expect { function_call }.to change { Activity.all.count }.by(6)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue