mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 20:34:50 +08:00
FEATURE: Upload Site Settings. (#6573)
This commit is contained in:
@ -1,11 +1,13 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe MetadataController do
|
||||
let(:upload) { Fabricate(:upload) }
|
||||
|
||||
describe 'manifest.webmanifest' do
|
||||
it 'returns the right output' do
|
||||
title = 'MyApp'
|
||||
SiteSetting.title = title
|
||||
SiteSetting.large_icon_url = "http://big.square/png"
|
||||
SiteSetting.large_icon = upload
|
||||
|
||||
get "/manifest.webmanifest"
|
||||
expect(response.status).to eq(200)
|
||||
@ -13,19 +15,28 @@ RSpec.describe MetadataController do
|
||||
manifest = JSON.parse(response.body)
|
||||
|
||||
expect(manifest["name"]).to eq(title)
|
||||
expect(manifest["icons"].first["src"]).to eq("http://big.square/png")
|
||||
|
||||
expect(manifest["icons"].first["src"]).to eq(
|
||||
UrlHelper.absolute(upload.url)
|
||||
)
|
||||
end
|
||||
|
||||
it 'can guess mime types' do
|
||||
SiteSetting.large_icon_url = "http://big.square/ico.jpg"
|
||||
upload = Fabricate(:upload,
|
||||
original_filename: 'test.jpg',
|
||||
extension: 'jpg'
|
||||
)
|
||||
|
||||
SiteSetting.large_icon = upload
|
||||
get "/manifest.webmanifest"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
manifest = JSON.parse(response.body)
|
||||
expect(manifest["icons"].first["type"]).to eq("image/jpeg")
|
||||
end
|
||||
|
||||
it 'defaults to png' do
|
||||
SiteSetting.large_icon_url = "http://big.square/noidea.bogus"
|
||||
SiteSetting.large_icon = upload
|
||||
get "/manifest.webmanifest"
|
||||
expect(response.status).to eq(200)
|
||||
manifest = JSON.parse(response.body)
|
||||
@ -57,15 +68,15 @@ RSpec.describe MetadataController do
|
||||
describe 'opensearch.xml' do
|
||||
it 'returns the right output' do
|
||||
title = 'MyApp'
|
||||
favicon_path = '/uploads/something/23432.png'
|
||||
SiteSetting.title = title
|
||||
SiteSetting.favicon_url = favicon_path
|
||||
SiteSetting.favicon = upload
|
||||
get "/opensearch.xml"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.body).to include(title)
|
||||
expect(response.body).to include("/search?q={searchTerms}")
|
||||
expect(response.body).to include('image/png')
|
||||
expect(response.body).to include(favicon_path)
|
||||
expect(response.body).to include(UrlHelper.absolute(upload.url))
|
||||
expect(response.content_type).to eq('application/xml')
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user