It should not be possible to change the 'global' property on an existing flag.

This regression is about the UI. We can file a task to enforce this at the API level too, or leave people able to hang themselves (as they could on D7).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim created an issue. See original summary.

joachim’s picture

Status: Needs review » Needs work

The last submitted patch, 2: 2694865-2.flag_.global-disabled-on-edit.patch, failed testing.

joachim’s picture

Oh dear, the tests are doing the opposite of what they're meant to!

joachim’s picture

Status: Needs review » Needs work

The last submitted patch, 5: 2694865-5.flag_.global-disabled-on-edit.patch, failed testing.

Berdir’s picture

I don't think that test method is called yet? the test only patch is supposed to fail...

What should we do with \Drupal\flag\Tests\FlagSimpleTest::doGlobalFlagLinksTest() then? That's the only global test coverage that there is right now. Move to a new test that creates a global flag and doesn't do the part about enabling and disabling the flag again?

joachim’s picture

Assigned: Unassigned » joachim

Drat! I didn't actually read the test result, as I only had about 5 minutes to reroll!

> Move to a new test that creates a global flag and doesn't do the part about enabling and disabling the flag again?

Yup, that makes sense.

socketwench’s picture

Status: Needs work » Needs review
FileSize
8.58 KB

Refactored the global flag tests to their own test class, but for some reason it's still failing locally.

Status: Needs review » Needs work

The last submitted patch, 9: 2694865-9.flag_.global-disabled-on-edit.patch, failed testing.

socketwench’s picture

Status: Needs work » Needs review
FileSize
8.43 KB

It'll still fail, but at least the flag link shows up the first time, after that, POOF!

Status: Needs review » Needs work

The last submitted patch, 11: 2694865-11.flag_.global-disabled-on-edit.patch, failed testing.

joachim’s picture

I was working on this one too...

I managed to get my refactoring to pass last night, but didn't have time to clean up and post a patch.

joachim’s picture

+++ b/src/Tests/FlagTestBase.php
@@ -68,11 +68,13 @@ abstract class FlagTestBase extends WebTestBase {
-  protected function createFlag($entity_type = 'node', $bundles = [], $link_type = 'reload') {
+  protected function createFlag($entity_type = 'node', $bundles = [], $link_type = 'reload', $global = FALSE) {

I pondered doing this, but I feel the more parameters we add to this helper method, the less helpful it becomes -- at some point, it will simply have parameters for all of the flag properties, and then it might as well have a single $config param, and then we're no longer saving very much effort at all.

My take on refactoring the tests is to move both of doFlagLinksTest/doFlagGlobalLinksTest to a new test that focuses on access to a flag based on ownership. In due course we can add a test class for access based on permission, and also the access_author option.

The last submitted patch, 14: 2694865-14.flag_.global-disabled-on-edit.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 14: 2694865-14.flag_.global-disabled-on-edit-tests-only.patch, failed testing.

Berdir’s picture

Test needed a quick fix because global is now a radio element. I'm just checking the first radio button now.

Also removed t() from the assertion message, we stopped doing that a while ago.

The last submitted patch, 17: 2694865-17.flag_.global-disabled-on-edit-test-only.patch, failed testing.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

I just did that minor change, everything else looks good to me. This blocks the load multiple issue, which is critical (which kind of makes this critical too), so would be nice to get it in.

  • joachim committed 6ba9fa8 on 8.x-4.x
    Issue #2694865 by joachim, Berdir, socketwench: Fixed Flag global...
joachim’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Status: Fixed » Closed (fixed)

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