mirror of
https://github.com/discourse/discourse.git
synced 2024-12-04 21:23:44 +08:00
e708c99e12
At the top of the theme show page we have a link to the theme About and License, which are supposed to be URLs. However some themes have left placeholder text in these metadata fields, which leads to a wonky experience. Instead, we can just not serialize these fields if they are not valid URLs, then they will not show as links in the UI.
38 lines
1.3 KiB
Ruby
38 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe RemoteThemeSerializer do
|
|
fab!(:remote_theme) do
|
|
Fabricate(
|
|
:remote_theme,
|
|
about_url: "https://meta.discourse.org/t/some-theme/123",
|
|
license_url: "https://github.com/repo/repo/LICENSE.md",
|
|
)
|
|
end
|
|
|
|
describe "about_url" do
|
|
it "returns the about_url" do
|
|
serialized = RemoteThemeSerializer.new(remote_theme).as_json[:remote_theme]
|
|
expect(serialized[:about_url]).to eq("https://meta.discourse.org/t/some-theme/123")
|
|
end
|
|
|
|
it "returns nil if the URL is not a valid URL" do
|
|
remote_theme.update!(about_url: "todo: Put your theme's public repo or Meta topic URL here")
|
|
serialized = RemoteThemeSerializer.new(remote_theme).as_json[:remote_theme]
|
|
expect(serialized[:about_url]).to be_nil
|
|
end
|
|
end
|
|
|
|
describe "license_url" do
|
|
it "returns the license_url" do
|
|
serialized = RemoteThemeSerializer.new(remote_theme).as_json[:remote_theme]
|
|
expect(serialized[:license_url]).to eq("https://github.com/repo/repo/LICENSE.md")
|
|
end
|
|
|
|
it "returns nil if the URL is not a valid URL" do
|
|
remote_theme.update!(license_url: "todo: Put your theme's LICENSE URL here")
|
|
serialized = RemoteThemeSerializer.new(remote_theme).as_json[:remote_theme]
|
|
expect(serialized[:license_url]).to be_nil
|
|
end
|
|
end
|
|
end
|