Skip to content

Commit

Permalink
allow importing admins by role_id
Browse files Browse the repository at this point in the history
fixes CNVS-39945

test plan
 - import admin with role id
 - it should work

Change-Id: Iea738b5422e9befd5a9c0179b26a897331143f34
Reviewed-on: https://gerrit.instructure.com/129617
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <[email protected]>
Product-Review: Rob Orton <[email protected]>
QA-Review: Rob Orton <[email protected]>
  • Loading branch information
roor0 authored and maneframe committed Oct 17, 2017
1 parent 4c71b43 commit d727913
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sis/admin_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def get_role(role_id, role)
@account_roles_by_account_id[@account.id] ||= @account.available_account_roles

@role = nil
@role = @account_roles_by_account_id[@account.id].detect {|r| r.id == role_id} if role_id
@role = @account_roles_by_account_id[@account.id].detect {|r| r.id.to_s == role_id} if role_id
@role ||= @account_roles_by_account_id[@account.id].detect {|r| r.name == role}
end
end
Expand Down
13 changes: 13 additions & 0 deletions spec/lib/sis/csv/admin_importer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,17 @@
)
expect(@account.account_users.active.count).to eq before_count + 1
end

it 'should add admins by role_id' do
user_with_managed_pseudonym(account: @account, sis_user_id: 'U001')

role = @sub_account.available_account_roles.first

before_count = AccountUser.active.count
process_csv_data_cleanly(
'user_id,account_id,role_id,status',
"U001,sub1,#{role.id.to_s},active"
)
expect(AccountUser.active.count).to eq before_count + 1
end
end

0 comments on commit d727913

Please sign in to comment.