Skip to content

Commit

Permalink
Monkeypatch ActionController::TestCase after app has loaded
Browse files Browse the repository at this point in the history
Otherwise, ApplicationController::TestCase gets loaded before
the application is initialized and this results in weird
behavior in some tests, particularly view specs.
  • Loading branch information
skanev committed Nov 23, 2011
1 parent 3f1d0b7 commit 5bd140f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/vanity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ module Vanity
require "vanity/playground"
require "vanity/helpers"
# Integration with various frameworks.
require "vanity/frameworks/rails" if defined?(Rails)
require "vanity/frameworks"
16 changes: 16 additions & 0 deletions lib/vanity/frameworks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Automatically configure Vanity.
if defined?(Rails)
if Rails.const_defined?(:Railtie) # Rails 3
class Plugin < Rails::Railtie # :nodoc:
initializer "vanity.require" do |app|
require 'vanity/frameworks/rails'
Vanity::Rails.load!
end
end
else
Rails.configuration.after_initialize do
require 'vanity/frameworks/rails'
Vanity::Rails.load!
end
end
end
16 changes: 0 additions & 16 deletions lib/vanity/frameworks/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,22 +304,6 @@ def setup_controller_request_and_response
end
end

# Automatically configure Vanity.
if defined?(Rails)
if Rails.const_defined?(:Railtie) # Rails 3
class Plugin < Rails::Railtie # :nodoc:
initializer "vanity.require" do |app|
Vanity::Rails.load!
end
end
else
Rails.configuration.after_initialize do
Vanity::Rails.load!
end
end
end


# Reconnect whenever we fork under Passenger.
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
Expand Down

0 comments on commit 5bd140f

Please sign in to comment.