Skip to content

Commit 0211989

Browse files
rmosolgovaclavbohac
authored andcommitted
Add tests for comment inheritance and nil
1 parent 2433e07 commit 0211989

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

spec/graphql/schema/interface_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,4 +681,22 @@ def pet(name:)
681681
end
682682
end
683683
end
684+
685+
describe ".comment" do
686+
it "isn't inherited" do
687+
int1 = Module.new do
688+
include GraphQL::Schema::Interface
689+
graphql_name "Int1"
690+
comment "TODO: fix this"
691+
end
692+
693+
int2 = Module.new do
694+
include int1
695+
graphql_name "Int2"
696+
end
697+
698+
assert_equal "TODO: fix this", int1.comment
699+
assert_nil int2.comment
700+
end
701+
end
684702
end

spec/graphql/schema/object_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,4 +489,22 @@ def self.wrap(obj, ctx)
489489
assert_equal expected_log, log
490490
end
491491
end
492+
493+
describe ".comment" do
494+
it "isn't inherited and can be set to nil" do
495+
obj1 = Class.new(GraphQL::Schema::Object) do
496+
graphql_name "Obj1"
497+
comment "TODO: fix this"
498+
end
499+
500+
obj2 = Class.new(obj1) do
501+
graphql_name("Obj2")
502+
end
503+
504+
assert_equal "TODO: fix this", obj1.comment
505+
assert_nil obj2.comment
506+
obj1.comment(nil)
507+
assert_nil obj1.comment
508+
end
509+
end
492510
end

0 commit comments

Comments
 (0)