Skip to content

Commit

Permalink
There are some cases where @@app is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Jul 27, 2016
1 parent d980abd commit 1a2f1c4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
6 changes: 5 additions & 1 deletion actionpack/lib/action_dispatch/testing/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 0 additions & 19 deletions actionpack/test/controller/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions railties/test/application/integration_test_case_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1a2f1c4

Please sign in to comment.