mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
There are some cases where @@app is not defined
This commit is contained in:
parent
61d4d738e1
commit
6da5186aaa
3 changed files with 33 additions and 20 deletions
|
@ -712,7 +712,11 @@ module ActionDispatch
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
def app
|
def app
|
||||||
@@app || ActionDispatch.test_app
|
if defined?(@@app) && @@app
|
||||||
|
@@app
|
||||||
|
else
|
||||||
|
ActionDispatch.test_app
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def app=(app)
|
def app=(app)
|
||||||
|
|
|
@ -397,25 +397,6 @@ class IntegrationTestUsesCorrectClass < ActionDispatch::IntegrationTest
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class IntegrationTestDefaultApp < ActionDispatch::IntegrationTest
|
|
||||||
def setup
|
|
||||||
@app = self.class.app
|
|
||||||
self.class.app = nil
|
|
||||||
|
|
||||||
@test_app = ActionDispatch.test_app
|
|
||||||
ActionDispatch.test_app = 'fake_app'
|
|
||||||
end
|
|
||||||
|
|
||||||
def teardown
|
|
||||||
self.class.app = @app
|
|
||||||
ActionDispatch.test_app = @test_app
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_class_app_returns_ad_test_app_by_default
|
|
||||||
assert_equal 'fake_app', self.class.app
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class IntegrationProcessTest < ActionDispatch::IntegrationTest
|
class IntegrationProcessTest < ActionDispatch::IntegrationTest
|
||||||
class IntegrationController < ActionController::Base
|
class IntegrationController < ActionController::Base
|
||||||
def get
|
def get
|
||||||
|
|
|
@ -43,4 +43,32 @@ module ApplicationTests
|
||||||
assert_match(/0 failures, 0 errors/, output)
|
assert_match(/0 failures, 0 errors/, output)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class IntegrationTestDefaultApp < ActiveSupport::TestCase
|
||||||
|
include ActiveSupport::Testing::Isolation
|
||||||
|
|
||||||
|
setup do
|
||||||
|
build_app
|
||||||
|
end
|
||||||
|
|
||||||
|
teardown do
|
||||||
|
teardown_app
|
||||||
|
end
|
||||||
|
|
||||||
|
test "app method of integration tests returns test_app by default" do
|
||||||
|
app_file 'test/integration/default_app_test.rb', <<-RUBY
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class DefaultAppIntegrationTest < ActionDispatch::IntegrationTest
|
||||||
|
def test_app_returns_action_dispatch_test_app_by_default
|
||||||
|
assert_equal ActionDispatch.test_app, app
|
||||||
|
end
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
|
||||||
|
output = Dir.chdir(app_path) { `bin/rails test 2>&1` }
|
||||||
|
assert_equal 0, $?.to_i, output
|
||||||
|
assert_match(/0 failures, 0 errors/, output)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue