8000 Add favicon to template app to fix Rails 7.2 test suite run by mgrunberg · Pull Request #8461 · activeadmin/activeadmin · GitHub
[go: up one dir, main page]

Skip to content

Add favicon to template app to fix Rails 7.2 test suite run #8461

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

Merged
merged 1 commit into from
Aug 31, 2024

Conversation

mgrunberg
Copy link
Contributor
@mgrunberg mgrunberg commented Aug 29, 2024

Our test suit fails due to

No route matches [GET] "/favicon.ico" (ActionController::RoutingError)

Our head partial does not define any icon tag which makes the browser request favicon.ico.

Rails 7.2 changed the icon of the new generated app from favicon.ico to a PNG file.

Copy link
codecov bot commented Aug 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.11%. Comparing base (72b8252) to head (f92213e).
Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8461   +/-   ##
=======================================
  Coverage   99.11%   99.11%           
=======================================
  Files         141      141           
  Lines        4069     4069           
=======================================
  Hits         4033     4033           
  Misses         36       36           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mgrunberg mgrunberg requested a review from javierjulio August 29, 2024 14:22
Copy link
Member
@javierjulio javierjulio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to do this with a partial and changing the layout. I know browsers will request that favicon file regardless. I believe we just need to include a dummy public/favicon.ico image in the generated app and that should resolve the issue. It shouldn't have to be user facing.

@javierjulio
Copy link
Member

@mgrunberg by including a dummy public/favicon.ico file I've confirmed that the tests pass consistently on Rails 7.2 with multiple runs. Once I remove it though, I encounter test failures. Would you mind if I push those changes here? I'd like to keep this focused on just resolving the failed tests for the generated app, nothing user facing.

@mgrunberg
Copy link
Contributor Author

@javierjulio can you recondider?
I don't like adding a favicon. If we favor something it should be new rails defaults (a PNG).

Trusting on favicon existance forces all new projects to install our views or tweak the favico (if they notice the missing icon).

In this sense, I prefere to render the icon meta if assests exists.

As a non so strong argument, I don't use favicon nor logo.png (new default). I don't want to install the head just for these.

All that been said, despite the extra effort, I'm not against fix the test in one PR and solve user facing problems in another.

@javierjulio
Copy link
Member

There isn't a user facing problem here though. There is no need to configure a favicon in the layout for them, they are expected to do that if they have one. They can update it as they need to. I don't understand why we'd want to configure something for them. It's not something we need to maintain in the layout file we copy over either. We just need it to fix our test suite where we are using the rails new command to generate a dummy app that is causing test failures. If they don't have a favicon, the browser will just log an error so it can be noisy but the site doesn't crash.

@mgrunberg mgrunberg changed the title Ability to config favicon Add favicon to template app Aug 30, 2024
We have some specs failing in Rails 7.2. The only hint we have in the
log is

```
No route matches [GET] "/favicon.ico" (ActionController::RoutingError)
```

Rails 7.2 new app generator does not use favicon.ico anymore. It uses a
png + meta "icon" tag.

Let's configure the icon in the template app to prevent this kind of
error.
@mgrunberg
Copy link
Contributor Author

I understand that you think adding the favicon back is the simplest change to fix the issues and I changed the PR to reflect that.

My point is that our layout uses an old Rails default which increases the chances that users need to make a customization. But site icon per see could require a customization anyway (I'm not using any of the Rails defaults for site icon).

Customizations are not good or wrong. After much thought, I realize I'm inclined to prevent customizations mostly because of the javascript we have on the head. So, I opened another PR (#8462) to change the only thing that makes me wonder about head customization. I hope you find both PR ok now.

@javierjulio
Copy link
Member

@mgrunberg ok great, thank you! Yes, this all we need, the simplest solution for now.

@javierjulio javierjulio changed the title Add favicon to template app Add favicon to template app to fix Rails 7.2 test suite run Aug 31, 2024
Copy link
Member
@javierjulio javierjulio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@javierjulio javierjulio merged commit 21e3244 into master Aug 31, 2024
25 checks passed
@javierjulio javierjulio deleted the config-favicon branch August 31, 2024 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development < 3981 /div>

Successfully merging this pull request may close these issues.

2 participants
0