mirror of
https://github.com/discourse/discourse.git
synced 2025-03-15 02:45:24 +08:00
Add test case for topic embed CSS
This commit is contained in:
parent
6c9190357c
commit
4a9dadb646
@ -71,19 +71,43 @@ describe EmbedController do
|
||||
|
||||
context "with a host" do
|
||||
let!(:embeddable_host) { Fabricate(:embeddable_host) }
|
||||
let(:headers) { { 'REFERER' => embed_url } }
|
||||
|
||||
before do
|
||||
SiteSetting.queue_jobs = false
|
||||
end
|
||||
|
||||
it "raises an error with no referer" do
|
||||
get '/embed/comments', params: { embed_url: embed_url }
|
||||
expect(response.body).to match(I18n.t('embed.error'))
|
||||
end
|
||||
|
||||
it "includes CSS from embedded_scss field" do
|
||||
theme = Theme.create!(name: "Awesome blog", user_id: -1)
|
||||
theme.set_default!
|
||||
|
||||
ThemeField.create!(
|
||||
theme_id: theme.id,
|
||||
name: "embedded_scss",
|
||||
target_id: 0,
|
||||
type_id: 1,
|
||||
value: ".test-osama-15 {\n" + " color: red;\n" + "}\n"
|
||||
)
|
||||
|
||||
topic_embed = Fabricate(:topic_embed, embed_url: embed_url)
|
||||
post = Fabricate(:post, topic: topic_embed.topic)
|
||||
|
||||
get '/embed/comments', params: { embed_url: embed_url }, headers: headers
|
||||
|
||||
html = Nokogiri::HTML.fragment(response.body)
|
||||
css_link = html.at("link[data-target=embedded_theme]").attribute("href").value
|
||||
|
||||
get css_link
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.body).to include(".test-osama-15")
|
||||
end
|
||||
|
||||
context "success" do
|
||||
let(:headers) { { 'REFERER' => embed_url } }
|
||||
|
||||
before do
|
||||
SiteSetting.queue_jobs = false
|
||||
end
|
||||
|
||||
after do
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.headers['X-Frame-Options']).to eq("ALLOWALL")
|
||||
|
Loading…
x
Reference in New Issue
Block a user