FEATURE: Support uploading a csv with either user emails or usernames (#8971)

This commit is contained in:
Roman Rizzi
2020-02-18 10:53:12 -03:00
committed by GitHub
parent be3e4ab3f5
commit 9441362c72
6 changed files with 39 additions and 9 deletions

View File

@@ -199,7 +199,7 @@ describe Admin::BadgesController do
expect(response.status).to eq(400)
end
it 'creates the badge for an existing user' do
it 'awards the badge using a list of user emails' do
Jobs.run_immediately!
user = Fabricate(:user, email: 'user1@test.com')
@@ -209,6 +209,17 @@ describe Admin::BadgesController do
expect(UserBadge.exists?(user: user, badge: badge)).to eq(true)
end
it 'awards the badge using a list of usernames' do
Jobs.run_immediately!
user = Fabricate(:user, username: 'username1')
file = file_from_fixtures('usernames.csv', 'csv')
post "/admin/badges/award/#{badge.id}.json", params: { file: fixture_file_upload(file) }
expect(UserBadge.exists?(user: user, badge: badge)).to eq(true)
end
end
end
end