Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle nil dependencies in case of inheritance #1620

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/tapioca/dsl/compilers/active_support_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def gather_constants

sig { params(concern: Module).returns(T::Array[Module]) }
def dependencies_of(concern)
concern.instance_variable_get(:@_dependencies)
concern.instance_variable_get(:@_dependencies) || []
end
end

Expand Down
21 changes: 21 additions & 0 deletions spec/tapioca/dsl/compilers/active_support_concern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,27 @@ class Bar
assert_equal([], gathered_constants_in_namespace(:TestCase))
end

it "does not gather constants that inherit from a class that extend ActiveSupport::Concern" do
add_ruby_file("test_case.rb", <<~RUBY)
module TestCase
module Foo
extend ActiveSupport::Concern
end

class Bar
extend ActiveSupport::Concern
include Foo
end

class Baz < Bar
include Foo
end
end
RUBY

assert_equal(["TestCase::Bar"], gathered_constants_in_namespace(:TestCase))
end

it "gathers constants for nested AS::Concern" do
add_ruby_file("test_case.rb", <<~RUBY)
module TestCase
Expand Down
Loading