Skip to content

Commit

Permalink
Serve static assets from Assets' @mount_path
Browse files Browse the repository at this point in the history
  • Loading branch information
fgrehm committed Apr 9, 2012
1 parent d5c8ec2 commit ecac2c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/harbor/assets.rb
Expand Up @@ -39,6 +39,7 @@ def cascade
end end


def find_file(file) def find_file(file)
file = file.gsub("#{@mount_path}/", '')
pattern = "{#{paths.join(',')}}/#{file}" pattern = "{#{paths.join(',')}}/#{file}"
Dir[pattern].first Dir[pattern].first
end end
Expand Down
8 changes: 4 additions & 4 deletions test/assets_test.rb
Expand Up @@ -23,22 +23,22 @@ def test_cascades_self_if_serve_static
end end


def test_does_not_match_if_not_enabled_to_serve_static def test_does_not_match_if_not_enabled_to_serve_static
refute @assets.match(stub_request('public-file')) refute @assets.match(stub_request('assets/public-file'))
end end


def test_matches_static_assets def test_matches_static_assets
@assets.serve_static = true @assets.serve_static = true
assert @assets.match(stub_request('public-file')) assert @assets.match(stub_request('assets/public-file'))
end end


def test_searches_on_multiple_paths def test_searches_on_multiple_paths
@assets.serve_static = true @assets.serve_static = true
assert @assets.match(stub_request('public-file-2')) assert @assets.match(stub_request('assets/public-file-2'))
end end


def test_return_nil_if_no_match_is_found def test_return_nil_if_no_match_is_found
@assets.serve_static = true @assets.serve_static = true
refute @assets.match(stub_request('public-file-3')) refute @assets.match(stub_request('assets/public-file-3'))
end end


def test_caches_and_stream_file def test_caches_and_stream_file
Expand Down

0 comments on commit ecac2c5

Please sign in to comment.