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

Applications do not follow component conventions #3369

Open
andysellick opened this issue Apr 28, 2023 · 2 comments
Open

Applications do not follow component conventions #3369

andysellick opened this issue Apr 28, 2023 · 2 comments
Assignees
Labels
in progress In progress issues are being worked on but may not be a high priority.

Comments

@andysellick
Copy link
Contributor

I'm doing a bit of a spike into making the component auditing report on components within applications, prompted by recent conversations. Turns out that our naming and file location conventions for components within the gem aren't always being followed by applications. Here's some (very) initial investigations.

For component templates:

Application Name Location
Gem _component_name.html.erb app/views/govuk_publishing_components/components/
Collections _component-name.html.erb app/views/components/
Finder-frontend _component-name.html.erb app/views/components/

For component test files:

Application Name Location
Gem component_name_spec.rb spec/components/
Collections component_name.html.erb_spec.rb spec/views/components/
Finder-frontend component_name_spec.rb spec/components/

This inconsistency is going to make auditing components in applications difficult, as we'd have to include specific details of all of these things on a per-application basis within the auditing. I'll have a look at whether applications could be restructured slightly instead.

@andysellick
Copy link
Contributor Author

There's an interesting inconsistency in government-frontend that's worth documenting. The component test files are in test/components so I looked into moving them into spec/components to match the gem.

We use two different systems for tests - RSpec and Minitest, and which directory the test should go in is related to the system. government-frontend uses Minitest, so the tests are in test/, and if we wanted to move them we'd have to rewrite them in RSpec first. That's probably not worth the effort for the sake of component auditing.

@andysellick andysellick self-assigned this May 3, 2023
@andysellick andysellick added the in progress In progress issues are being worked on but may not be a high priority. label May 3, 2023
@andysellick andysellick added this to To do in Component issues May 3, 2023
@MartinJJones
Copy link
Contributor

MartinJJones commented May 4, 2023

I was having a quick look at this issue and how we can try to avoid using incorrect file names in the future.

When I followed the documentation to Create a new component in the application, I ran the command below to generate a new component:

rails generate govuk_publishing_components:component new_component_name

However, the file name for the component view template included hyphens instead of underscores.

government-frontend % rails generate govuk_publishing_components:component new_component_name
      create  app/views/components/_new-component-name.html.erb
      create  app/views/components/docs/new-component-name.yml
      create  app/assets/stylesheets/components/_new-component-name.scss

This could also be worth looking into further, but might be beyond the scope of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress In progress issues are being worked on but may not be a high priority.
Projects
Component issues
  
In progress
Development

No branches or pull requests

2 participants