Skip to content

Commit

Permalink
Removes require_dependency from the AR test suite
Browse files Browse the repository at this point in the history
In the AR test suite require_dependency does not make much sense. Just
call vanilla require/load.

Note that in the test that made explicit use of it, there are no
autoload paths, and no constants have been autoloaded. In reality, the
code ended up calling Kernel#load.
  • Loading branch information
fxn committed May 6, 2020
1 parent 92d3afe commit afabe99
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions activerecord/test/cases/multiple_db_test.rb
Expand Up @@ -57,12 +57,11 @@ def test_associations
assert_equal e3.course.id, c2.id
end

def test_course_connection_should_survive_dependency_reload
def test_course_connection_should_survive_reloads
assert Course.connection

ActiveSupport::Dependencies.clear
Object.send(:remove_const, :Course)
require_dependency "models/course"
assert Object.send(:remove_const, :Course)
assert load("models/course.rb")

assert Course.connection
end
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/models/college.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require_dependency "models/arunit2_model"
require "models/arunit2_model"
require "active_support/core_ext/object/with_options"

class College < ARUnit2Model
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/models/course.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require_dependency "models/arunit2_model"
require "models/arunit2_model"

class Course < ARUnit2Model
belongs_to :college
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/models/other_dog.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require_dependency "models/arunit2_model"
require "models/arunit2_model"

class OtherDog < ARUnit2Model
self.table_name = "dogs"
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/models/professor.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require_dependency "models/arunit2_model"
require "models/arunit2_model"

class Professor < ARUnit2Model
has_and_belongs_to_many :courses
Expand Down

0 comments on commit afabe99

Please sign in to comment.