Merge pull request #1617 from jbargu/jg_3244

Duplicated activity, report activity ... [SCI-3244]
This commit is contained in:
Jure Grabnar 2019-04-01 14:31:53 +02:00 committed by GitHub
commit 83130426e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 4 deletions

View file

@ -263,7 +263,7 @@ class Experiment < ApplicationRecord
def archive_modules(module_ids, current_user)
my_modules.where(id: module_ids).each do |my_module|
my_module.archive!(current_user)
log_activity(:archive_task, current_user, my_module)
log_activity(:archive_module, current_user, my_module)
end
my_modules.reload
end

View file

@ -17,6 +17,7 @@ module ReportActions
cell.destroy if cell
@new_cell_value = create_new_cell_value(asset)
@new_cell_value.save
log_activity
end
def error_messages
@ -107,6 +108,18 @@ module ReportActions
return content unless content.blank?
I18n.t('projects.reports.new.no_content_for_PDF_html')
end
def log_activity
Activities::CreateActivityService
.call(activity_type: :edit_item_inventory,
owner: @user,
subject: @repository,
team: @team,
message_items: {
repository_row: @repository_item.id,
repository: @repository.id
})
end
end
RepositoryPermissionError = Class.new(StandardError)

View file

@ -107,6 +107,8 @@ module RepositoryImportParser
errors = true
raise ActiveRecord::Rollback
end
log_activity(record_row)
@new_rows_added += 1
end
end
@ -155,5 +157,18 @@ module RepositoryImportParser
end
current_column
end
def log_activity(repository_row)
Activities::CreateActivityService.call(
activity_type: :create_item_inventory,
owner: @user,
subject: @repository,
team: @repository.team,
message_items: {
repository_row: repository_row.id,
repository: @repository.id
}
)
end
end
end

View file

@ -13,7 +13,7 @@ en:
custom_dates_label: "Select custom dates"
from_label: "Select end date"
to_label: "Select start date"
clear: "clear"
clear: "Clear"
activity_type: "Activity type"
user: "User"
object: "Object"
@ -181,7 +181,6 @@ en:
restore_experiment: "Experiment restored"
rename_task: "Task renamed"
move_task: "Task moved"
archive_task: "Task archived"
set_task_due_date: "Task due date set"
change_task_due_date: "Task due date changed"
remove_task_due_date: "Task due date removed"

View file

@ -180,7 +180,7 @@ describe Experiment, type: :model do
expect(Activities::CreateActivityService)
.to(receive(:call)
.with(hash_including(activity_type:
:archive_task))).exactly(3).times
:archive_module))).exactly(3).times
function_call
end