Skip to content
Browse files

Merge pull request #4147 from lest/remove-app-fallback

remove Rails application fallback from AD::IntegrationTest
  • Loading branch information...
2 parents 9bbe2b8 + 5f3b9de commit 34bbf8428cd5d1cf2bc9c1ce222a84fe5488a34e @josevalim josevalim committed
View
3 actionpack/lib/action_dispatch.rb
@@ -29,6 +29,7 @@
require 'active_support'
require 'active_support/dependencies/autoload'
+require 'active_support/core_ext/module/attribute_accessors'
require 'action_pack'
require 'active_model'
@@ -88,6 +89,8 @@ module Session
autoload :CacheStore, 'action_dispatch/middleware/session/cache_store'
end
+ mattr_accessor :test_app
+
autoload_under 'testing' do
autoload :Assertions
autoload :Integration
View
2 actionpack/lib/action_dispatch/railtie.rb
@@ -28,6 +28,8 @@ class Railtie < Rails::Railtie
config.action_dispatch.always_write_cookie = Rails.env.development? if config.action_dispatch.always_write_cookie.nil?
ActionDispatch::Cookies::CookieJar.always_write_cookie = config.action_dispatch.always_write_cookie
+
+ ActionDispatch.test_app = app
end
end
end
View
9 actionpack/lib/action_dispatch/testing/integration.rb
@@ -463,9 +463,12 @@ class IntegrationTest < ActiveSupport::TestCase
@@app = nil
def self.app
- # DEPRECATE Rails application fallback
- # This should be set by the initializer
- @@app || (defined?(Rails.application) && Rails.application) || nil
+ if !@@app && !ActionDispatch.test_app
+ ActiveSupport::Deprecation.warn "Rails application fallback is deprecated " \
+ "and no longer works, please set ActionDispatch.test_app", caller
+ end
+
+ @@app || ActionDispatch.test_app
end
def self.app=(app)
View
5 railties/test/application/configuration_test.rb
@@ -282,6 +282,11 @@ def index
assert_equal res, last_response.body # value should be unchanged
end
+ test "sets ActionDispatch.test_app" do
+ make_basic_app
+ assert_equal Rails.application, ActionDispatch.test_app
+ end
+
test "sets all Active Record models to whitelist all attributes by default" do
add_to_config <<-RUBY
config.active_record.whitelist_attributes = true

0 comments on commit 34bbf84

Please sign in to comment.
Something went wrong with that request. Please try again.