forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SIS import: ensure imported users have a name
also, don't remove an existing name if the import doesn't specify one test plan: - if a SIS import creates a new user and all of the following columns are missing or blank, the login_id should be used as the name. * full_name * first_name * last_name * sortable_name * short_name - if a SIS import updates an existing user and does not specify any of the above columns, the user's name should remain unchanged (not blanked out!) fixes ADMIN-579 Change-Id: Id6297bdac3cf13c7561c713b3cd983af3d1ed3c3 Reviewed-on: https://gerrit.instructure.com/136307 Reviewed-by: Jon Willesen <[email protected]> QA-Review: Deepeeca Soundarrajan <[email protected]> Tested-by: Jenkins Product-Review: Jeremy Stanley <[email protected]>
- Loading branch information
Showing
3 changed files
with
66 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,20 +194,41 @@ def gen_ssha_password(password) | |
expect(user.last_name).to eq 'St. Clair' | ||
end | ||
|
||
it "should tolerate blank first and last names" do | ||
it "uses sortable_name if none of first_name/last_name/full_name is given" do | ||
process_csv_data_cleanly( | ||
"user_id,login_id,first_name,last_name,email,status", | ||
"user_1,user1,,,[email protected],active" | ||
"user_id,login_id,sortable_name,short_name,email,status", | ||
"user_1,user1,blah,bleh,[email protected],active" | ||
) | ||
user = CommunicationChannel.by_path('[email protected]').first.user | ||
expect(user.name).to eql(" ") | ||
user = Pseudonym.by_unique_id('user1').first.user | ||
expect(user.name).to eq 'blah' | ||
end | ||
|
||
it "uses short_name is none of first_name/last_name/full_name/sortable_name is given" do | ||
process_csv_data_cleanly( | ||
"user_id,login_id,email,status", | ||
"user_2,user2,user2@example.com,active" | ||
"user_id,login_id,short_name,email,status", | ||
"user_1,user1,bleh,user@example.com,active" | ||
) | ||
user = CommunicationChannel.by_path('[email protected]').first.user | ||
expect(user.name).to eql(" ") | ||
user = Pseudonym.by_unique_id('user1').first.user | ||
expect(user.name).to eq 'bleh' | ||
end | ||
|
||
it "uses login_id as a name if no form of name is given" do | ||
process_csv_data_cleanly( | ||
"user_id,login_id,status", | ||
"user_1,user1,active" | ||
) | ||
user = Pseudonym.by_unique_id('user1').first.user | ||
expect(user.name).to eq 'user1' | ||
end | ||
|
||
it "should leave the name alone if no name is supplied for an existing user" do | ||
user = User.create!(:name => 'Greeble') | ||
user.pseudonyms.create!(:account => @account, :sis_user_id => 'greeble', :unique_id => '[email protected]') | ||
process_csv_data_cleanly( | ||
"user_id,login_id,status", | ||
"greeble,[email protected],active" | ||
) | ||
expect(user.reload.name).to eq 'Greeble' | ||
end | ||
|
||
it "should ignore first and last names if full name is provided" do | ||
|