Skip to content

Commit 817310a

Browse files
committed
use compression when appropriate
1 parent 830ffab commit 817310a

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

lib/sassc/rails/template.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def call(input)
1313
syntax: self.class.syntax,
1414
load_paths: input[:environment].paths,
1515
importer: SassC::Rails::Importer,
16+
style: sass_style,
1617
sprockets: {
1718
context: context,
1819
environment: input[:environment],
@@ -43,6 +44,7 @@ def evaluate(context, locals, &block)
4344
syntax: syntax,
4445
load_paths: context.environment.paths,
4546
importer: SassC::Rails::Importer,
47+
style: sass_style,
4648
sprockets: {
4749
context: context,
4850
environment: context.environment
@@ -58,6 +60,11 @@ def evaluate(context, locals, &block)
5860
else
5961
include Sprockets2
6062
end
63+
64+
def sass_style
65+
style = Rails.application.config.sass.style || :expanded
66+
"sass_style_#{style}".to_sym
67+
end
6168
end
6269

6370
class ScssTemplate < SassTemplate

test/sassc_rails_test.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def render_asset(asset)
3030
end
3131

3232
def initialize!
33+
Rails.env = "test"
3334
@app.initialize!
3435
end
3536

@@ -44,13 +45,14 @@ def initialize_prod!
4445
end
4546

4647
def test_setup_works
47-
initialize!
48+
initialize_dev!
4849

4950
asset = render_asset("application.scss")
5051

5152
assert_equal <<-CSS, asset
5253
.hello {
53-
color: #FFF; }
54+
color: #FFF;
55+
}
5456
CSS
5557
end
5658

@@ -166,7 +168,12 @@ def test_special_characters_compile
166168
end
167169

168170
def test_compression_works
169-
skip
171+
initialize_prod!
172+
173+
asset = render_asset("application.scss")
174+
assert_equal <<-CSS, asset
175+
.hello{color:#FFF}
176+
CSS
170177
end
171178

172179
#test 'sprockets require works correctly' do

0 commit comments

Comments
 (0)