Skip to content

Commit

Permalink
Use first prefix is multiple prefixes are defined
Browse files Browse the repository at this point in the history
fix petebrowne/sprockets-helpers/#24
  • Loading branch information
kathgironpe committed Apr 10, 2014
1 parent e898d50 commit 8e19035
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/sprockets/helpers.rb
Expand Up @@ -36,6 +36,7 @@ class << self
# This defaults to '/assets'.
def prefix
@prefix ||= '/assets'
@prefix.is_a?(Array) ? "/#{@prefix.first}" : @prefix
end
attr_writer :prefix

Expand Down
14 changes: 14 additions & 0 deletions spec/sprockets-helpers_spec.rb
Expand Up @@ -564,6 +564,20 @@
expect(Sprockets::Helpers.digest).to be_true
end

it 'uses first prefix if assets_prefix is an array' do
custom_env = Sprockets::Environment.new

app = Class.new(Sinatra::Base) do
set :sprockets, custom_env
set :assets_prefix, %w(assets vendor/assets)

register Sinatra::Sprockets::Helpers
end

expect(Sprockets::Helpers.environment).to be(custom_env)
expect(Sprockets::Helpers.prefix).to eq('/assets')
end

it 'manually configures with configure method' do
custom_env = Sprockets::Environment.new

Expand Down

0 comments on commit 8e19035

Please sign in to comment.