mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
UX: Add image uploader widget for uploading badge images (#12377)
Currently the process of adding a custom image to badge is quite clunky; you have to upload your image to a topic, and then copy the image URL and pasting it in a text field. Besides being clucky, if the topic or post that contains the image is deleted, the image will be garbage-collected in a few days and the badge will lose the image because the application is not that the image is referenced by a badge. This commit improves that by adding a proper image uploader widget for badge images.
This commit is contained in:
@ -138,6 +138,7 @@ describe Admin::BadgesController do
|
||||
it 'updates the badge' do
|
||||
SiteSetting.enable_badge_sql = true
|
||||
sql = "select id user_id, created_at granted_at from users"
|
||||
image = Fabricate(:upload)
|
||||
|
||||
put "/admin/badges/#{badge.id}.json", params: {
|
||||
name: "123456",
|
||||
@ -145,13 +146,17 @@ describe Admin::BadgesController do
|
||||
badge_type_id: badge.badge_type_id,
|
||||
allow_title: false,
|
||||
multiple_grant: false,
|
||||
enabled: true
|
||||
enabled: true,
|
||||
image_upload_id: image.id,
|
||||
icon: "fa-rocket",
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
badge.reload
|
||||
expect(badge.name).to eq('123456')
|
||||
expect(badge.query).to eq(sql)
|
||||
expect(badge.image_upload.id).to eq(image.id)
|
||||
expect(badge.icon).to eq("fa-rocket")
|
||||
end
|
||||
|
||||
context 'when there is a user with a title granted using the badge' do
|
||||
|
Reference in New Issue
Block a user