FEATURE: Small improvements to the topic list embed (#12881)

* FEATURE: Small improvements to the topic list embed

- Ability to wrap the list in a custom class so you can styles different
lists using specific CSS

- Adds a topic link to the thumbnail when using the complete template

* FIX: Be more strict about allowed chars in class name
This commit is contained in:
Rafael dos Santos Silva
2021-04-29 12:12:00 -03:00
committed by GitHub
parent 15eabb1d97
commit e2154b3d59
3 changed files with 19 additions and 3 deletions

View File

@ -100,7 +100,7 @@ describe EmbedController do
expect(response.body).to match("data-referer=\"https://example.com/evil-trout\"")
end
it "returns a list of topics" do
it "returns a list of top topics" do
bad_topic = Fabricate(:topic)
good_topic = Fabricate(:topic, like_count: 1000, posts_count: 100)
TopTopic.refresh!
@ -116,6 +116,16 @@ describe EmbedController do
expect(response.body).to match("data-referer=\"https://example.com/evil-trout\"")
end
it "wraps the list in a custom class" do
topic = Fabricate(:topic)
get '/embed/topics?discourse_embed_id=de-1234&embed_class=my-special-class', headers: {
'REFERER' => 'https://example.com/evil-trout'
}
expect(response.status).to eq(200)
expect(response.headers['X-Frame-Options']).to be_nil
expect(response.body).to match("class='topics-list my-special-class'")
end
it "returns no referer if not supplied" do
get '/embed/topics?discourse_embed_id=de-1234'
expect(response.status).to eq(200)