Problem/Motivation

We only set job items to active when the old status is unprocessed. If a job is rejected, then the status is set to rejected and afterwards, the job itesm are not activated.

Proposed resolution

Activate job items if the previous job state was unprocessed or rejected (or if the status is not active?)

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

tduong’s picture

Assigned: Unassigned » tduong
tduong’s picture

Edited Job::preSave() check, added test, small refactoring.

Screenshots:

  • job state: state of the jobs before and after the changes
  • job item state before
  • job item state after
Berdir’s picture

Status: Needs review » Needs work
+++ b/src/Tests/TMGMTUiTest.php
@@ -578,6 +577,69 @@ class TMGMTUiTest extends EntityTestBase {
+    // Check that job is in rejected and job item is in active state.
+    $job1 = \Drupal::entityTypeManager()->getStorage('tmgmt_job')->loadUnchanged($job1->id());
+    $this->assertTrue($job1->isRejected());
+    $item1 = \Drupal::entityTypeManager()->getStorage('tmgmt_job_item')->loadUnchanged($item1->id());
+    $this->assertTrue($item1->isActive());

That's not the idea. reject should not set it to active. only active should.

You need to resubmit the same job in the test.

First try with reject, that will change the status to rejected. check that status is reject and inactive. Then submit the same job again, this time with submit. Then check that job and item is active.

It would be a lot faster if we could do this through the API, for example in TmgmtCrudTest. set $job->translator and $job->settings['action'] (I think), then requestTranslation().

The last submitted patch, 3: job_items_not_active_if_rejected-2695217-3-test_only.patch, failed testing.

tduong’s picture

Restarted as suggested above: changed fix and rewrote test, thus no interdiff.

Screenshots to see the job/job item states of the test's steps:

  • job reject
  • job item reject
  • job submit
  • job item submit

The last submitted patch, 6: job_items_not_active_if_rejected-2695217-6-test_only.patch, failed testing.

tduong’s picture

After discussion with @Berdir, moved the test to tmgmt/tests/src/Kernel/CrudTest.php and improved it (for performance/complexity reason).

Berdir’s picture

Status: Needs review » Fixed

Be careful with unrelated fixes. You risk that your patch conflicts with others that might be changing those lines as well for another reason. Only fix coding standards and documentation in lines that you touch anyway.

Test looks good now. Was confused why you added the use, the problem was actually something else, the namespace was wrong. Fixed and committed:

diff --git a/tests/src/Kernel/CrudTest.php b/tests/src/Kernel/CrudTest.php
index 8903a28..a7fb80e 100644
--- a/tests/src/Kernel/CrudTest.php
+++ b/tests/src/Kernel/CrudTest.php
@@ -4,9 +4,8 @@
  * Contains \Drupal\tmgmt\tests\Kernel\CrudTest.
  */
 
-namespace Drupal\tmgmt\tests\Kernel;
+namespace Drupal\Tests\tmgmt\Kernel;
 
-use Drupal\Tests\tmgmt\Kernel\TMGMTKernelTestBase;
 use Drupal\tmgmt\ContinuousTranslatorInterface;
 use Drupal\tmgmt\Entity\Job;
 use Drupal\tmgmt\Entity\JobItem;

  • Berdir committed 05da637 on 8.x-1.x authored by tduong
    Issue #2695217 by tduong, Berdir: Job items are not set to active if the...
tduong’s picture

About the unrelated fixed: ok! :)
About the namespace: why is it Drupal\Tests\tmgmt\Kernel ? Is there something special for kernel folders / Unit tests ?

I'm confused how the test_only patch could pass, and why this is fine since you have committed it :/

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jansi.n’s picture

FileSize
105.96 KB
146 KB

Below section details the steps of how for a rejected job, even if we succeed from memsource provider the job status doesn’t change to inprogress as expected. We are using TMGMT 8.1.12. Can you suggest if you can assist with a patch for this version to fix our issue?

Thanks!

Steps followed to replicate issue:
1. While creating Jobs and sending to memsource, we encountered that the jobs were “rejected”. The status of Job was set as Rejected.
2. On resending the same job, the Job was accepted by Memsource, the accepted ID was recorded in the log of the specified Job.
joblogs

3. Though the Job was successfully submitted to memsource, the job status continued to be as “rejected”.
rejectjobstatus

4. Completed the translation of this Job in Memsource
5. Unable to pull the translations back from memsource as the Job was in “rejected” state