Skip to content

Commit

Permalink
Add test to verify that creating accounts is case insensitive, and up…
Browse files Browse the repository at this point in the history
…date the accounts controller
  • Loading branch information
bbpennel committed Jul 22, 2024
1 parent ebae8b7 commit cd76250
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def ensure_admin!
end

def create_user(onyen)
onyen = onyen.downcase
email = "#{onyen}@ad.unc.edu"
if User.where(uid: onyen).blank?
user = User.where(uid: onyen).first_or_create(provider: 'shibboleth', email: email)
Expand Down
6 changes: 6 additions & 0 deletions spec/controllers/accounts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
expect(response).to redirect_to('/admin/users?locale=en')
expect(flash[:notice]).to eq "A user account for #{invalid_attributes[:onyen]}@ad.unc.edu already exists."
end

it 'catches case differences' do
post :create, params: { account: { onyen: 'AdMiN' } }
expect(response).to redirect_to('/admin/users?locale=en')
expect(flash[:notice]).to eq "A user account for #{invalid_attributes[:onyen]}@ad.unc.edu already exists."
end
end
end

Expand Down

0 comments on commit cd76250

Please sign in to comment.