Skip to content

Commit

Permalink
Sprockets-rails tests fail
Browse files Browse the repository at this point in the history
Method invalid_asset_host! was delegated to controller but sprockets
compile assets in their own scope without controller. And if we set asset_host
with second parameter it should raise error through invalid_asset_host!.
But since controller is nil it cannot be reached.
  • Loading branch information
route committed Sep 1, 2012
1 parent 5f99bdb commit 3a6e8e4
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 18 deletions.
1 change: 0 additions & 1 deletion actionpack/lib/action_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module ActionController
autoload :Middleware

autoload_under "metal" do
autoload :AssetPaths
autoload :Compatibility
autoload :ConditionalGet
autoload :Cookies
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ def self.without_modules(*modules)
MODULES = [
AbstractController::Layouts,
AbstractController::Translation,
AbstractController::AssetPaths,

AssetPaths,
Helpers,
HideActions,
UrlFor,
Expand Down
13 changes: 0 additions & 13 deletions actionpack/lib/action_controller/metal/asset_paths.rb

This file was deleted.

1 change: 1 addition & 0 deletions actionpack/lib/action_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ module ActionView
autoload :MissingTemplate
autoload :ActionViewError
autoload :EncodingError
autoload :MissingRequestError
autoload :TemplateError
autoload :WrongEncodingError
end
Expand Down
8 changes: 5 additions & 3 deletions actionpack/lib/action_view/asset_paths.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
require 'zlib'
require 'active_support/core_ext/file'
require 'active_support/core_ext/module/delegation'
require 'action_controller/metal/exceptions'

module ActionView
class AssetPaths #:nodoc:
URI_REGEXP = %r{^[-a-z]+://|^(?:cid|data):|^//}

attr_reader :config, :controller

delegate :invalid_asset_host!, :to => :controller, :prefix => false

def initialize(config, controller = nil)
@config = config
@controller = controller
Expand Down Expand Up @@ -99,6 +97,10 @@ def default_protocol
@config.default_asset_host_protocol || (has_request? ? :request : :relative)
end

def invalid_asset_host!(help_message)
raise ActionView::MissingRequestError, "This asset host cannot be computed without a request in scope. #{help_message}"
end

# Pick an asset host for this source. Returns +nil+ if no host is set,
# the host if no wildcard is set, the host interpolated with the
# numbers 0-3 if it contains <tt>%d</tt> (the number is the source hash mod 4),
Expand Down
3 changes: 3 additions & 0 deletions actionpack/lib/action_view/template/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ class ActionViewError < StandardError #:nodoc:
class EncodingError < StandardError #:nodoc:
end

class MissingRequestError < StandardError #:nodoc:
end

class WrongEncodingError < EncodingError #:nodoc:
def initialize(string, encoding)
@string, @encoding = string, encoding
Expand Down

0 comments on commit 3a6e8e4

Please sign in to comment.