MDL-68905 core_badges: remove issuer details from edit page
authorSara Arjona <sara@moodle.com>
Wed, 3 Jun 2020 17:34:07 +0000 (19:34 +0200)
committerSara Arjona <sara@moodle.com>
Wed, 3 Jun 2020 17:38:09 +0000 (19:38 +0200)
In MDL-68746 issuer details fields were removed from the badges
form, because they are filled from the site settings.
This is a regression because these fields should be removed also
from the edit page.

badges/edit.php
badges/tests/behat/add_badge.feature

index 2307d0d..d52a7c8 100644 (file)
@@ -100,9 +100,11 @@ if ($form->is_cancelled()) {
         $badge->imageauthorurl = $data->imageauthorurl;
         $badge->imagecaption = $data->imagecaption;
         $badge->usermodified = $USER->id;
-        $badge->issuername = $data->issuername;
-        $badge->issuerurl = $data->issuerurl;
-        $badge->issuercontact = $data->issuercontact;
+        if (badges_open_badges_backpack_api() == OPEN_BADGES_V1) {
+            $badge->issuername = $data->issuername;
+            $badge->issuerurl = $data->issuerurl;
+            $badge->issuercontact = $data->issuercontact;
+        }
         $badge->expiredate = ($data->expiry == 1) ? $data->expiredate : null;
         $badge->expireperiod = ($data->expiry == 2) ? $data->expireperiod : null;
 
index 09db662..bc7695d 100644 (file)
@@ -166,3 +166,32 @@ Feature: Add badges to the system
     And I click on "Site badges" "link" in the "Navigation" "block"
     Then I should see "Manage badges"
     And I should see "Add a new badge"
+
+  @javascript @_file_upload
+  Scenario: Edit a badge
+    Given I navigate to "Badges > Badges settings" in site administration
+    And I set the field "Badge issuer name" to "Test Badge Site"
+    And I set the field "Badge issuer email address" to "testuser@example.com"
+    And I press "Save changes"
+    And I navigate to "Badges > Add a new badge" in site administration
+    And I set the following fields to these values:
+      | Name | Test badge with 'apostrophe' and other friends (<>&@#) |
+      | Version | firstversion |
+      | Language | English |
+      | Description | Test badge description |
+      | Image author | http://author.example.com |
+      | Image caption | Test caption image |
+    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
+    And I press "Create badge"
+    When I follow "Edit details"
+    And I should see "Test badge with 'apostrophe' and other friends (&@#)"
+    And I should not see "Issuer details"
+    And I set the following fields to these values:
+      | Name | Test badge renamed |
+      | Version | secondversion |
+    And I press "Save changes"
+    And I follow "Overview"
+    Then I should not see "Test badge with 'apostrophe' and other friends (&@#)"
+    And I should not see "firstversion"
+    And I should see "Test badge renamed"
+    And I should see "secondversion"