FIX: Get correct selectable avatar from URL (#10339)

The URL for selectable avatars was 'cooked' which means that the find_by
method was not enough.
This commit is contained in:
Bianca Nenciu
2020-08-03 17:15:41 +03:00
committed by GitHub
parent e6349685d3
commit 2682da81ad
3 changed files with 14 additions and 3 deletions

View File

@@ -2377,6 +2377,17 @@ describe UsersController do
expect(user.reload.uploaded_avatar_id).to eq(avatar1.id)
expect(user.user_avatar.reload.custom_upload_id).to eq(avatar1.id)
end
it 'can succesfully select an avatar using a cooked URL' do
events = DiscourseEvent.track_events do
put "/u/#{user.username}/preferences/avatar/select.json", params: { url: UrlHelper.cook_url(avatar1.url) }
end
expect(events.map { |event| event[:event_name] }).to include(:user_updated)
expect(response.status).to eq(200)
expect(user.reload.uploaded_avatar_id).to eq(avatar1.id)
expect(user.user_avatar.reload.custom_upload_id).to eq(avatar1.id)
end
end
end
end