Skip to content

Commit

Permalink
MDL-60801 tool_uploaduser: Fix issue with defaults being ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewhancox committed Nov 24, 2017
1 parent 5bde2c2 commit 1744570
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion admin/tool/uploaduser/index.php
Expand Up @@ -358,7 +358,7 @@

// add default values for remaining fields
$formdefaults = array();
if ($updatetype != UU_UPDATE_FILEOVERRIDE && $updatetype != UU_UPDATE_NOCHANGES) {
if (!$existinguser || ($updatetype != UU_UPDATE_FILEOVERRIDE && $updatetype != UU_UPDATE_NOCHANGES)) {
foreach ($STD_FIELDS as $field) {
if (isset($user->$field)) {
continue;
Expand Down
25 changes: 25 additions & 0 deletions admin/tool/uploaduser/tests/behat/upload_users.feature
Expand Up @@ -38,6 +38,31 @@ Feature: Upload users
And I set the field "groups" to "Section 1 (1)"
And the "members" select box should contain "Tom Jones"

@javascript
Scenario: Upload users enrolling them on courses and groups applying defaults
Given the following "courses" exist:
| fullname | shortname | category |
| Maths | math102 | 0 |
And the following "groups" exist:
| name | course | idnumber |
| Section 1 | math102 | S1 |
| Section 3 | math102 | S3 |
And I log in as "admin"
And I navigate to "Upload users" node in "Site administration > Users > Accounts"
When I upload "lib/tests/fixtures/upload_users.csv" file to "File" filemanager
And I press "Upload users"
And I set the following fields to these values:
| City/town | Brighton |
| Department | Purchasing |
And I press "Upload users"
And I press "Continue"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I should see "Tom Jones"
And I follow "Tom Jones"
And I follow "Edit profile"
And the field "City/town" matches value "Brighton"
And the field "Department" matches value "Purchasing"

@javascript
Scenario: Upload users with custom profile fields
# Create user profile field.
Expand Down

0 comments on commit 1744570

Please sign in to comment.