Permalink
Browse files

Refactored duplicate initialization logic for Rails 2 and 3

  • Loading branch information...
1 parent 6c0e120 commit 38136a6bc9c451c30f205619b6e0dbf9fe58c959 @rondevera rondevera committed Dec 20, 2010
@@ -0,0 +1 @@
+ActionView::Base.send(:include, ::AssetHatHelper)
@@ -0,0 +1 @@
+AssetHat.cache_last_commit_ids unless defined?(::IRB)
View
@@ -5,11 +5,11 @@
module AssetHat
class Railtie < Rails::Railtie #:nodoc:
initializer 'asset_hat.action_view' do |app|
- ActionView::Base.send(:include, ::AssetHatHelper)
+ require 'asset_hat/initializers/action_view'
end
initializer 'asset_hat.cache_last_commit_ids' do |app|
- AssetHat.cache_last_commit_ids unless defined?(::IRB)
+ require 'asset_hat/initializers/cache_last_commit_ids'
end
rake_tasks do
View
@@ -1,2 +1,2 @@
-::ActionView::Base.send(:include, AssetHatHelper)
-AssetHat.cache_last_commit_ids unless defined?(::IRB)
+require 'asset_hat/initializers/action_view'
+require 'asset_hat/initializers/cache_last_commit_ids'
@@ -441,8 +441,14 @@ def flexmock_rails_app
:config => flexmock(:consider_all_requests_local => true),
:env_defaults => {}
))
+
+ if ActionController::Base.respond_to?(:consider_all_requests_local)
+ # Rails 2.x
+ flexmock(ActionController::Base, :consider_all_requests_local => true)
+ end
+
if defined?(config) # Rails 3.x
- config[:assets_dir] = AssetHat::ASSETS_DIR
+ config.assets_dir = AssetHat::ASSETS_DIR
end
end

0 comments on commit 38136a6

Please sign in to comment.