Skip to content

Commit

Permalink
Merge pull request #13 from Tonksthebear/opt-out-of-base-classes-hotfix
Browse files Browse the repository at this point in the history
Fix bug with base not properly being skipped in components (tests did…
  • Loading branch information
Tonksthebear committed Mar 28, 2024
2 parents fc62b8a + 04e1c00 commit b23135b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
Binary file added classy-yaml-1.2.1.gem
Binary file not shown.
Binary file removed classy-yaml-1.2.gem
Binary file not shown.
12 changes: 9 additions & 3 deletions lib/classy/yaml/component_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ def yass(*args)
component_name = self.class.name.underscore.split("/").last.split(".").first

classy_files = ["#{calling_path}/#{component_name}.yml",
"#{calling_path}/#{calling_file}/#{calling_file}.yml",
"#{calling_path}/#{calling_file}/#{component_name}.yml"
"#{calling_path}/#{calling_file}/#{calling_file}.yml",
"#{calling_path}/#{calling_file}/#{component_name}.yml"
]

helpers.yass(args, classy_files: classy_files.uniq)
if args.first.is_a?(Hash)
args.first.merge!({ classy_files: classy_files.uniq })
else
args << { classy_files: classy_files.uniq }
end

helpers.yass(*args)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/classy/yaml/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Classy
module Yaml
VERSION = '1.2'
VERSION = '1.2.1'
end
end
5 changes: 3 additions & 2 deletions test/classy/yaml_component_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class Classy::YamlComponentTest < ViewComponent::TestCase
end

test "can skip base" do
render_inline(TestComponent.new classy: {nested_base: :nested, skip_base: true})
assert_text "nested-class"
render_inline(TestComponent.new classy: {overrideable_nested: :nested, skip_base: true})
assert_no_text 'component-nested-base-class'
assert_text "component-nested-class"
end
end

0 comments on commit b23135b

Please sign in to comment.