2015-10-11 05:41:23 -04:00
|
|
|
require 'rails_helper'
|
2014-05-02 17:46:03 -04:00
|
|
|
require_dependency 'sass/discourse_stylesheets'
|
|
|
|
|
|
|
|
describe DiscourseStylesheets do
|
|
|
|
|
|
|
|
describe "compile" do
|
|
|
|
it "can compile desktop bundle" do
|
|
|
|
DiscoursePluginRegistry.stubs(:stylesheets).returns(["#{Rails.root}/spec/fixtures/scss/my_plugin.scss"])
|
|
|
|
builder = described_class.new(:desktop)
|
2015-05-05 16:52:03 -04:00
|
|
|
expect(builder.compile(force: true)).to include('my-plugin-thing')
|
2014-05-02 17:46:03 -04:00
|
|
|
FileUtils.rm builder.stylesheet_fullpath
|
|
|
|
end
|
|
|
|
|
|
|
|
it "can compile mobile bundle" do
|
|
|
|
DiscoursePluginRegistry.stubs(:mobile_stylesheets).returns(["#{Rails.root}/spec/fixtures/scss/my_plugin.scss"])
|
|
|
|
builder = described_class.new(:mobile)
|
2015-05-05 16:52:03 -04:00
|
|
|
expect(builder.compile(force: true)).to include('my-plugin-thing')
|
2014-05-02 17:46:03 -04:00
|
|
|
FileUtils.rm builder.stylesheet_fullpath
|
|
|
|
end
|
|
|
|
|
|
|
|
it "can fallback when css is bad" do
|
|
|
|
DiscoursePluginRegistry.stubs(:stylesheets).returns([
|
|
|
|
"#{Rails.root}/spec/fixtures/scss/my_plugin.scss",
|
|
|
|
"#{Rails.root}/spec/fixtures/scss/broken.scss"
|
|
|
|
])
|
|
|
|
builder = described_class.new(:desktop)
|
2015-05-05 16:52:03 -04:00
|
|
|
expect(builder.compile(force: true)).not_to include('my-plugin-thing')
|
2014-05-02 17:46:03 -04:00
|
|
|
FileUtils.rm builder.stylesheet_fullpath
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|