Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: curation log avoid duplicate if same curator #2023

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions protected/controllers/AdminDatasetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ public function actionUpdate($id)

//curator
$curatorId = $postDataset['curator_id'];
if ($curatorId !== $model->curator_id) {

if ((int) $curatorId !== (int) $model->curator_id) {
CurationLog::createlog_assign_curator($id, $curatorId);
$model->curator_id = $curatorId;
}
Expand Down Expand Up @@ -541,7 +542,7 @@ private function renderNotificationsAccordingToStatus($uploadStatus, $previousSt
$statusIsSet = true;
}

if ($statusIsSet) {
if (($previousStatus !== $uploadStatus) && $statusIsSet) {
CurationLog::createlog($uploadStatus, $model->id);
}
}
Expand Down
52 changes: 52 additions & 0 deletions tests/functional/AdminDatasetCurationLogCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

/**
* run with:
* docker-compose run --rm test ./vendor/codeception/codeception/codecept run functional AdminDatasetCurationLogCest
*/
class AdminDatasetCurationLogCest
{
public function checkCurationLogIsNotUpdatedIfCuratorNotUpdated(FunctionalTester $I)
{
$I->amOnPage('/site/login');
$I->submitForm('form.form-horizontal', [
'LoginForm[username]' => '[email protected]',
'LoginForm[password]' => 'gigadb'
]
);
$I->amOnPage('adminDataset/update/id/5');
$I->seeNumberOfElements('.table tbody tr', 1);
$I->canSee('No results found.');
$I->checkOption('#Dataset_Epigenomic');
$I->click('Save');

$I->canSee('Updated successfully!');
$I->cantSee('No results found.');
$I->canSee('Status changed to ImportFromEM');
$I->seeNumberOfElements('.table tbody tr', 1);
}

public function checkCurationLogIsUpdatedIfCuratorIsUpdated(FunctionalTester $I)
{
$I->amOnPage('/site/login');
$I->submitForm('form.form-horizontal', [
'LoginForm[username]' => '[email protected]',
'LoginForm[password]' => 'gigadb'
]
);
$I->amOnPage('adminDataset/update/id/5');
$I->seeNumberOfElements('.table tbody tr', 1);
$I->canSee('No results found.');
$I->selectOption('form select[id=Dataset_curator_id]', 988);
$I->click('Save');

$I->canSee('Updated successfully!');

$I->cantSee('No results found.');
$I->canSee('Status changed to ImportFromEM');
$I->canSee('Curator Assigned: Chris A');
$I->seeNumberOfElements('.table tbody tr', 2);
}
}