1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

[Sass] Don't die in Sass::Plugin if the :cache option is set but the :cache_location option isn't.

This commit is contained in:
Nathan Weizenbaum 2009-12-24 12:06:51 -08:00
parent 64f1ada692
commit e3a1aa4a5f
3 changed files with 34 additions and 5 deletions

View file

@ -20,6 +20,9 @@
{Sass::Script::Functions::EvaluationContext Functions::EvaluationContext}).
Now the module simply needs to be included in {Sass::Script::Functions}.
* Fixed a bug where {Sass::Plugin} would die if caching was enabled
but the cache location wasn't explicitly set.
## [2.2.15](http://github.com/nex3/haml/commit/2.2.15)
* Added {Sass::Script::Color#with} for a way of setting color channels

View file

@ -84,7 +84,7 @@ module Sass
private
def sassc_filename(filename, options)
File.join(options[:cache_location],
File.join(options[:cache_location] || Sass::Engine::DEFAULT_OPTIONS[:cache_location],
Digest::SHA1.hexdigest(File.dirname(File.expand_path(filename))),
File.basename(filename) + 'c')
end

View file

@ -32,7 +32,7 @@ class SassPluginTest < Test::Unit::TestCase
File.delete(tempfile_loc('basic'))
assert Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
Sass::Plugin.update_stylesheets
assert !Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
assert_stylesheet_updated 'basic'
end
def test_update_needed_when_modified
@ -40,7 +40,7 @@ class SassPluginTest < Test::Unit::TestCase
FileUtils.touch(template_loc('basic'))
assert Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
Sass::Plugin.update_stylesheets
assert !Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
assert_stylesheet_updated 'basic'
end
def test_update_needed_when_dependency_modified
@ -48,7 +48,7 @@ class SassPluginTest < Test::Unit::TestCase
FileUtils.touch(template_loc('basic'))
assert Sass::Plugin.stylesheet_needs_update?('import', template_loc, tempfile_loc)
Sass::Plugin.update_stylesheets
assert !Sass::Plugin.stylesheet_needs_update?('import', template_loc, tempfile_loc)
assert_stylesheet_updated 'basic'
end
def test_full_exception_handling
@ -116,7 +116,7 @@ class SassPluginTest < Test::Unit::TestCase
Merb::Rack::Application.new.call(::Rack::MockRequest.env_for('/'))
end
assert !Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
assert_stylesheet_updated 'basic'
end
def test_doesnt_render_partials
@ -138,6 +138,21 @@ class SassPluginTest < Test::Unit::TestCase
FileUtils.mv(template_loc("basic", "more_"), template_loc("basic"))
end
def test_update_with_cache_but_without_cache_location
old_cache = Sass::Plugin.options[:cache]
old_cache_location = Sass::Plugin.options[:cache_location]
Sass::Plugin.options[:cache] = true
Sass::Plugin.options[:cache_location] = nil
# We just want to make sure this doesn't raise an exception
FileUtils.touch(template_loc('basic'))
Sass::Plugin.update_stylesheets
assert_stylesheet_updated 'basic'
ensure
Sass::Plugin.options[:cache] = old_cache
Sass::Plugin.options[:cache_location] = old_cache_location
end
private
def assert_renders_correctly(*arguments)
@ -161,6 +176,17 @@ class SassPluginTest < Test::Unit::TestCase
end
end
def assert_stylesheet_updated(name)
assert !Sass::Plugin.stylesheet_needs_update?(name, template_loc, tempfile_loc)
# Make sure it isn't an exception
expected_lines = File.read(result_loc(name)).split("\n")
actual_lines = File.read(tempfile_loc(name)).split("\n")
if actual_lines.first == "/*" && expected_lines.first != "/*"
assert(false, actual_lines[0..actual_lines.enum_with_index.find {|l, i| l == "*/"}.last].join("\n"))
end
end
def template_loc(name = nil, prefix = nil)
if name
absolutize "#{prefix}templates/#{name}.sass"