mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-24 07:44:46 +08:00
Reset relationship counter when duplication repository row [SCI-9930] (#6881)
This commit is contained in:
parent
c3f8e873e9
commit
9e26d24dc9
2 changed files with 27 additions and 1 deletions
|
@ -48,7 +48,9 @@ module RepositoryActions
|
|||
name: "#{name} (1)",
|
||||
created_by_id: user_id,
|
||||
created_at: timestamp,
|
||||
updated_at: timestamp }
|
||||
updated_at: timestamp,
|
||||
parent_connections_count: 0,
|
||||
child_connections_count: 0 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,6 +22,7 @@ describe RepositoryActions::DuplicateRows do
|
|||
describe '#call' do
|
||||
before do
|
||||
@rows_ids = []
|
||||
@rows = []
|
||||
|
||||
3.times do |index|
|
||||
row = create :repository_row, name: "row (#{index})",
|
||||
|
@ -40,7 +41,17 @@ describe RepositoryActions::DuplicateRows do
|
|||
repository_column: list_column
|
||||
}
|
||||
@rows_ids << row.id.to_s
|
||||
@rows << row
|
||||
end
|
||||
|
||||
create :repository_row_connection, parent: @rows.first,
|
||||
child: @rows.second,
|
||||
created_by: user,
|
||||
last_modified_by: user
|
||||
create :repository_row_connection, parent: @rows.last,
|
||||
child: @rows.first,
|
||||
created_by: user,
|
||||
last_modified_by: user
|
||||
end
|
||||
|
||||
it 'generates a duplicate of selected items' do
|
||||
|
@ -93,5 +104,18 @@ describe RepositoryActions::DuplicateRows do
|
|||
expect { described_class.new(user, repository, @rows_ids).call }
|
||||
.to(change { Activity.count }.by(3))
|
||||
end
|
||||
|
||||
it 'do not create new connections in DB' do
|
||||
expect { described_class.new(user, repository, @rows_ids).call }
|
||||
.to(change { RepositoryRowConnection.count }.by(0))
|
||||
end
|
||||
|
||||
it 'reset connections counters' do
|
||||
described_class.new(user, repository, [@rows_ids.first]).call
|
||||
duplicated_row = repository.repository_rows.order('created_at ASC').last
|
||||
|
||||
expect(duplicated_row.parent_connections_count).to eq 0
|
||||
expect(duplicated_row.child_connections_count).to eq 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue