2017-04-19 15:46:28 -05:00
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe ThemeField do
|
|
|
|
it "correctly generates errors for transpiled js" do
|
|
|
|
html = <<HTML
|
|
|
|
<script type="text/discourse-plugin" version="0.8">
|
|
|
|
badJavaScript(;
|
|
|
|
</script>
|
|
|
|
HTML
|
2017-08-30 23:06:56 -05:00
|
|
|
|
2017-05-02 15:01:01 -05:00
|
|
|
field = ThemeField.create!(theme_id: 1, target_id: 0, name: "header", value: html)
|
2017-04-19 15:46:28 -05:00
|
|
|
expect(field.error).not_to eq(nil)
|
2017-08-30 23:06:56 -05:00
|
|
|
|
|
|
|
field.update!(value: '')
|
2017-04-19 15:46:28 -05:00
|
|
|
expect(field.error).to eq(nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "correctly generates errors for transpiled css" do
|
|
|
|
css = "body {"
|
2017-05-02 15:01:01 -05:00
|
|
|
field = ThemeField.create!(theme_id: 1, target_id: 0, name: "scss", value: css)
|
2017-04-19 15:46:28 -05:00
|
|
|
field.reload
|
|
|
|
expect(field.error).not_to eq(nil)
|
2017-04-20 15:55:09 -05:00
|
|
|
field.value = "body {color: blue};"
|
2017-04-19 15:46:28 -05:00
|
|
|
field.save!
|
2017-04-20 15:55:09 -05:00
|
|
|
field.reload
|
|
|
|
|
2017-04-19 15:46:28 -05:00
|
|
|
expect(field.error).to eq(nil)
|
|
|
|
end
|
2017-05-10 13:43:05 -05:00
|
|
|
|
2017-04-19 15:46:28 -05:00
|
|
|
end
|