Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactored duplicate initialization logic for Rails 2 and 3

  • Loading branch information...
commit 38136a6bc9c451c30f205619b6e0dbf9fe58c959 1 parent 6c0e120
Ron DeVera rondevera authored
1  lib/asset_hat/initializers/action_view.rb
View
@@ -0,0 +1 @@
+ActionView::Base.send(:include, ::AssetHatHelper)
1  lib/asset_hat/initializers/cache_last_commit_ids.rb
View
@@ -0,0 +1 @@
+AssetHat.cache_last_commit_ids unless defined?(::IRB)
4 lib/asset_hat/railtie.rb
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
4 rails/init.rb
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'
8 test/asset_hat_helper_test.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.