diff --git a/app/models/my_module.rb b/app/models/my_module.rb index d572d6608..27474778c 100644 --- a/app/models/my_module.rb +++ b/app/models/my_module.rb @@ -433,6 +433,8 @@ class MyModule < ApplicationRecord clone.save! + clone.assign_user(current_user) + # Remove the automatically generated protocol, # & clone the protocol instead clone.protocol.destroy diff --git a/spec/models/experiment_spec.rb b/spec/models/experiment_spec.rb index c68ca534d..978f9af09 100644 --- a/spec/models/experiment_spec.rb +++ b/spec/models/experiment_spec.rb @@ -189,12 +189,12 @@ describe Experiment, type: :model do expect(Activities::CreateActivityService) .to(receive(:call) .with(hash_including(activity_type: - :assign_user_to_module))).exactly(3).times + :assign_user_to_module))).exactly(6).times function_call end - it 'creats 3 new activities in DB' do - expect { function_call }.to change { Activity.all.count }.by(6) + it 'creats 9 new activities in DB (6 for assigning user, 3 for cloning module)' do + expect { function_call }.to change { Activity.all.count }.by(9) end end