Remove dead code and test custom classes on bare AvatarComponents
MODIFY
app/components/primer/avatar_component.rb
app/components/primer/avatar_component.rb
@@ -33,6 +33,7 @@ module Primer
@system_arguments[:size] = size
@system_arguments[:height] = size
@system_arguments[:width] = size
+
@system_arguments[:classes] = class_names(
system_arguments[:classes],
"avatar",
@@ -47,7 +48,7 @@ module Primer
render(Primer::BaseComponent.new(**@system_arguments.except(:classes))) { content }
end
else
- render(Primer::BaseComponent.new(classes: @classes, **@system_arguments)) { content }
+ render(Primer::BaseComponent.new(**@system_arguments)) { content }
end
end
end

MODIFY
test/components/avatar_component_test.rb
test/components/avatar_component_test.rb
@@ -36,6 +36,12 @@ class PrimerAvatarComponentTest < Minitest::Test
refute_selector(".avatar--small")
end
+ def test_adds_custom_classes
+ render_inline(Primer::AvatarComponent.new(src: "https://github.com/github.png", alt: "github", classes: "custom-class"))
+
+ assert_selector("img.avatar.custom-class")
+ end
+
def test_sets_size_height_and_width
render_inline(Primer::AvatarComponent.new(src: "https://github.com/github.png", alt: "github", size: 50))

Remove dead code and test custom classes on bare AvatarComponents