Add test case for topic embed CSS

This commit is contained in:
OsamaSayegh 2018-06-12 08:21:41 +03:00 committed by Sam
parent 6c9190357c
commit 4a9dadb646
1 changed files with 30 additions and 6 deletions

View File

@ -71,19 +71,43 @@ describe EmbedController do
context "with a host" do context "with a host" do
let!(:embeddable_host) { Fabricate(:embeddable_host) } 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 it "raises an error with no referer" do
get '/embed/comments', params: { embed_url: embed_url } get '/embed/comments', params: { embed_url: embed_url }
expect(response.body).to match(I18n.t('embed.error')) expect(response.body).to match(I18n.t('embed.error'))
end 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 context "success" do
let(:headers) { { 'REFERER' => embed_url } }
before do
SiteSetting.queue_jobs = false
end
after do after do
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(response.headers['X-Frame-Options']).to eq("ALLOWALL") expect(response.headers['X-Frame-Options']).to eq("ALLOWALL")