提交 1a2f1c48 编写于 作者: S Santiago Pastorino

There are some cases where @@app is not defined

上级 d980abdb
......@@ -717,7 +717,11 @@ module Behavior
module ClassMethods
def app
@@app || ActionDispatch.test_app
if defined?(@@app) && @@app
@@app
else
ActionDispatch.test_app
end
end
def app=(app)
......
......@@ -397,25 +397,6 @@ def test_integration_methods_called
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 IntegrationController < ActionController::Base
def get
......
......@@ -42,4 +42,32 @@ class MailerIntegrationTest < ActionDispatch::IntegrationTest
assert_match(/0 failures, 0 errors/, output)
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册