mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-27 17:30:32 +08:00
Add activity for copying Inventory and Invetory item
This commit is contained in:
parent
b3aa6be23d
commit
b91f08fe99
8 changed files with 58 additions and 7 deletions
|
@ -113,6 +113,13 @@ class Repository < ApplicationRecord
|
|||
end
|
||||
|
||||
# If everything is okay, return new_repo
|
||||
Activities::CreateActivityService
|
||||
.call(activity_type: :copy_inventory,
|
||||
owner: created_by,
|
||||
subject: new_repo,
|
||||
team: new_repo.team,
|
||||
message_items: { repository_new: new_repo.id, repository_original: id })
|
||||
|
||||
new_repo
|
||||
end
|
||||
|
||||
|
|
|
@ -36,6 +36,13 @@ module RepositoryActions
|
|||
row.repository_cells.each do |cell|
|
||||
duplicate_repository_cell(cell, new_row)
|
||||
end
|
||||
|
||||
Activities::CreateActivityService
|
||||
.call(activity_type: :copy_inventory_item,
|
||||
owner: @user,
|
||||
subject: @repository,
|
||||
team: @repository.team,
|
||||
message_items: { repository_row_new: new_row.id, repository_row_original: row.id })
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div class="ga-breadcrumb">
|
||||
<span class="fas fa-list-alt"></span>
|
||||
<% if subject %>
|
||||
<%= route_to_other_team(repositories_path(subject),
|
||||
<%= route_to_other_team(repository_path(subject.id),
|
||||
team,
|
||||
subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
|
||||
title: subject.name) %>
|
||||
|
|
|
@ -209,7 +209,9 @@ class Extends
|
|||
export_system_logs: 98,
|
||||
edit_wopi_file_on_result: 99,
|
||||
edit_wopi_file_on_step: 100,
|
||||
edit_wopi_file_on_step_in_repository: 101
|
||||
edit_wopi_file_on_step_in_repository: 101,
|
||||
copy_inventory: 105,
|
||||
copy_inventory_item: 102
|
||||
}.freeze
|
||||
|
||||
ACTIVITY_GROUPS = {
|
||||
|
@ -220,8 +222,8 @@ class Extends
|
|||
task_inventory: [55, 56],
|
||||
experiment: [*27..31, 57],
|
||||
reports: [48, 49, 50],
|
||||
inventories: [*70..78],
|
||||
protocol_repository: [*79..91],
|
||||
inventories: [*70..78, 105, 102],
|
||||
protocol_repository: [*79..91, 101],
|
||||
team: [*92..96],
|
||||
exports: [*97..98]
|
||||
}.freeze
|
||||
|
|
|
@ -106,11 +106,13 @@ en:
|
|||
delete_item_inventory_html: "%{user} deleted inventory item %{repository_row}."
|
||||
create_column_inventory_html: "%{user} created column %{repository_column} in inventory %{repository}."
|
||||
edit_column_inventory_html: "%{user} edited column %{repository_column} in inventory %{repository}."
|
||||
copy_inventory_html: "%{user} copied inventory %{repository_new} from inventory %{repository_original} as template"
|
||||
copy_inventory_item_html: "%{user} copied inventory item %{repository_row_new} from inventory item %{repository_row_original}"
|
||||
delete_column_inventory_html: "%{user} deleted column %{repository_column} in inventory %{repository}."
|
||||
create_protocol_in_repository_html: "%{user} created protocol %{protocol} in Protocol repository."
|
||||
add_step_to_protocol_repository_html: "%{user} created protocol %{protocol}'s step <strong>%{step}</strong> in Protocol repository."
|
||||
edit_step_in_protocol_repository_html: "%{user} edited protocol %{protocol}'s step <strong>%{step}</strong> in Protocol repository."
|
||||
delete_step_in_protocol_repository_html: "%{user} deleted protocol %{protocol}'s step <strong>%{step}</strong> in Protocol repository."
|
||||
add_step_to_protocol_repository_html: "%{user} created protocol %{protocol}'s step %{step_position} <strong>%{step}</strong> in Protocol repository."
|
||||
edit_step_in_protocol_repository_html: "%{user} edited protocol %{protocol}'s step %{step_position} <strong>%{step}</strong> in Protocol repository."
|
||||
delete_step_in_protocol_repository_html: "%{user} deleted protocol %{protocol}'s step %{step_position} <strong>%{step}</strong> in Protocol repository."
|
||||
edit_description_in_protocol_repository_html: "%{user} edited protocol %{protocol}'s description in Protocol repository."
|
||||
edit_keywords_in_protocol_repository_html: "%{user} edited protocol %{protocol}'s keywords in Protocol repository."
|
||||
edit_authors_in_protocol_repository_html: "%{user} edited protocol %{protocol}'s authors in Protocol repository."
|
||||
|
@ -201,6 +203,8 @@ en:
|
|||
delete_item_inventory: "Inventory item deleted"
|
||||
create_column_inventory: "Inventory column created"
|
||||
edit_column_inventory: "Inventory column edited"
|
||||
copy_inventory: "Inventory copied"
|
||||
copy_inventory_item: "Inventory item copied"
|
||||
delete_column_inventory: "Inventory column deleted"
|
||||
update_protocol_in_repository_from_task: "Protocol updated from task"
|
||||
create_protocol_in_repository: "Protocol created"
|
||||
|
|
|
@ -803,6 +803,7 @@ ActiveRecord::Schema.define(version: 20190304153544) do
|
|||
t.bigint "assigned_by_id"
|
||||
t.index ["assigned_by_id"], name: "index_user_projects_on_assigned_by_id"
|
||||
t.index ["project_id"], name: "index_user_projects_on_project_id"
|
||||
t.index ["user_id", "project_id"], name: "index_user_projects_on_user_id_and_project_id", unique: true
|
||||
t.index ["user_id"], name: "index_user_projects_on_user_id"
|
||||
end
|
||||
|
||||
|
@ -828,6 +829,7 @@ ActiveRecord::Schema.define(version: 20190304153544) do
|
|||
t.bigint "assigned_by_id"
|
||||
t.index ["assigned_by_id"], name: "index_user_teams_on_assigned_by_id"
|
||||
t.index ["team_id"], name: "index_user_teams_on_team_id"
|
||||
t.index ["user_id", "team_id"], name: "index_user_teams_on_user_id_and_team_id", unique: true
|
||||
t.index ["user_id"], name: "index_user_teams_on_user_id"
|
||||
end
|
||||
|
||||
|
|
|
@ -42,4 +42,21 @@ describe Repository, type: :model do
|
|||
expect(repo).to_not be_valid
|
||||
end
|
||||
end
|
||||
|
||||
describe '.copy' do
|
||||
let(:created_by) { create :user }
|
||||
let(:repository) { create :repository }
|
||||
|
||||
it 'calls create activity for copying inventory' do
|
||||
expect(Activities::CreateActivityService)
|
||||
.to(receive(:call).with(hash_including(activity_type: :copy_inventory)))
|
||||
|
||||
repository.copy(created_by, 'name for copied repo')
|
||||
end
|
||||
|
||||
it 'adds activity in DB' do
|
||||
expect { repository.copy(created_by, 'name for copied repo') }
|
||||
.to(change { Activity.count })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -79,5 +79,17 @@ describe RepositoryActions::DuplicateRows do
|
|||
service_obj.call
|
||||
expect(service_obj.number_of_duplicated_items).to eq 0
|
||||
end
|
||||
|
||||
it 'calls create activity for copying intentory items 3 times' do
|
||||
expect(Activities::CreateActivityService)
|
||||
.to(receive(:call).with(hash_including(activity_type: :copy_inventory_item))).exactly(3).times
|
||||
|
||||
described_class.new(user, repository, @rows_ids).call
|
||||
end
|
||||
|
||||
it 'adds 3 activities in DB' do
|
||||
expect { described_class.new(user, repository, @rows_ids).call }
|
||||
.to(change { Activity.count }.by(3))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue