diff --git a/app/controllers/my_modules_controller.rb b/app/controllers/my_modules_controller.rb
index efa55a7b1..47340ec25 100644
--- a/app/controllers/my_modules_controller.rb
+++ b/app/controllers/my_modules_controller.rb
@@ -266,13 +266,15 @@ class MyModulesController < ApplicationController
new_status = @my_module.my_module_status_flow.my_module_statuses.find_by(id: update_status_params[:status_id])
return render_404 unless new_status
+ old_status_id = @my_module.my_module_status_id
@my_module.update(my_module_status: new_status)
- render json: { content: render_to_string(
- partial: 'my_modules/status_flow/task_flow_button.html.erb',
- locals: { my_module: @my_module })
- }, status: :ok
+ 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)
+ render json: { content: render_to_string(
+ partial: 'my_modules/status_flow/task_flow_button.html.erb', locals: { my_module: @my_module }
+ ) }, status: :ok
end
private
diff --git a/config/initializers/extends.rb b/config/initializers/extends.rb
index 25f7c4064..1a72da2c7 100644
--- a/config/initializers/extends.rb
+++ b/config/initializers/extends.rb
@@ -143,8 +143,11 @@ class Extends
step: nil
}
- ACTIVITY_MESSAGE_ITEMS_TYPES = ACTIVITY_SUBJECT_TYPES + %w(User Tag RepositoryColumn RepositoryRow Step
- Asset TinyMceAsset Repository RepositorySnapshot).freeze
+ ACTIVITY_MESSAGE_ITEMS_TYPES =
+ ACTIVITY_SUBJECT_TYPES + %w(
+ User Tag RepositoryColumn RepositoryRow Step Asset TinyMceAsset Repository MyModuleStatus RepositorySnapshot
+ ).freeze
+
ACTIVITY_TYPES = {
create_project: 0,
@@ -288,13 +291,15 @@ class Extends
archive_inventory: 144,
restore_inventory: 145,
export_inventory_items_assigned_to_task: 146,
- export_inventory_snapshot_items_assigned_to_task: 147
+ export_inventory_snapshot_items_assigned_to_task: 147,
+ change_status_on_task_flow: 148 # 149, 150, 151 in AdddOn!
}
ACTIVITY_GROUPS = {
projects: [*0..7, 32, 33, 34, 95, 108, 65, 109],
task_results: [23, 26, 25, 42, 24, 40, 41, 99, 110, 122, 116, 128],
- task: [8, 58, 9, 59, *10..14, 35, 36, 37, 53, 54, *60..63, 138, 139, 140, 64, *66..69, 106, 126, 120, 132],
+ task: [8, 58, 9, 59, *10..14, 35, 36, 37, 53, 54, *60..63, 138, 139, 140, 64, 66, 106, 126, 120, 132,
+ *146..148],
task_protocol: [15, 22, 16, 18, 19, 20, 21, 17, 38, 39, 100, 111, 45, 46, 47, 121, 124, 115, 118, 127, 130, 137],
task_inventory: [55, 56],
experiment: [*27..31, 57],
diff --git a/config/locales/global_activities/en.yml b/config/locales/global_activities/en.yml
index 0ab5de4c1..4003537e1 100644
--- a/config/locales/global_activities/en.yml
+++ b/config/locales/global_activities/en.yml
@@ -175,6 +175,7 @@ en:
protocol_description_in_task_edited_html: "%{user} edited protocol description on task %{my_module}."
export_inventory_items_assigned_to_task_html: "%{user} exported inventory item(s) assigned to task %{my_module} from inventory %{repository}: Live version."
export_inventory_snapshot_items_assigned_to_task_html: "%{user} exported inventory item(s) assigned to task %{my_module} from inventory %{repository_snapshot}: Snapshot of %{created_at}."
+ change_status_on_task_flow_html: "%{user} changed status from %{my_module_status_old} to %{my_module_status_new} for task %{my_module}."
activity_name:
create_project: "Project created"
@@ -315,6 +316,7 @@ en:
protocol_description_in_task_edited: "Protocol description in task edited"
export_inventory_items_assigned_to_task: "Task-assigned inventory items exported (live version)"
export_inventory_snapshot_items_assigned_to_task: "Task-assigned inventory items exported (snapshot)"
+ change_status_on_task_flow: "Task status changed"
activity_group:
projects: "Projects"
diff --git a/spec/controllers/my_modules_controller_spec.rb b/spec/controllers/my_modules_controller_spec.rb
index 5d98262ea..b407cdb5c 100644
--- a/spec/controllers/my_modules_controller_spec.rb
+++ b/spec/controllers/my_modules_controller_spec.rb
@@ -147,6 +147,10 @@ describe MyModulesController, type: :controller do
expect(my_module.reload.my_module_status.id).to be_eql(status_id)
expect(response).to have_http_status 200
end
+
+ it 'creates activity' do
+ expect { action }.to(change { Activity.all.count }.by(1))
+ end
end
context 'when status not found' do