Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

skip registering ActiveAdmin::Comment if namespace.comments is false#8710

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
FeLvi-zzz wants to merge6 commits intoactiveadmin:master
base:master
Choose a base branch
Loading
fromFeLvi-zzz:not-to-register-activeadmin-comment-if-disabled

Conversation

@FeLvi-zzz
Copy link

@FeLvi-zzzFeLvi-zzz commentedMay 6, 2025
edited
Loading

resolve#5117
resolve#5311

background

we disable comments, but routes are still drawn.

what to do

  • skip registering ActiveAdmin::Comment if namespace.comments is disabled and resources in namespace are disabled
    • this prevents drawing routes for comments
    • something for model (scope, before_save) are unneeded as well

@FeLvi-zzzFeLvi-zzz marked this pull request as draftMay 6, 2025 05:18
@FeLvi-zzzFeLvi-zzz marked this pull request as ready for reviewMay 6, 2025 05:24
@tagliala
Copy link
Contributor

Hello,

thanks for this PR

Any chance to add a spec to cover this scenario?

@FeLvi-zzz
Copy link
Author

@tagliala
Hello,

yes, but which file should I add a spec into?
I couldn't find an appropriate one, it looks like there is nothing testing likenamespace.register ActiveAdmin::Comment.
I would appreciate if you could let me know where to add.

@tagliala
Copy link
Contributor

This looks like aroutes spec. There is one underresource

Asking@javierjulio for confirmation

FeLvi-zzz reacted with thumbs up emoji

@javierjulio
Copy link
Member

@tagliala I'm not sure actually.@FeLvi-zzz let's give that a try please and we'll go from there.

FeLvi-zzz reacted with thumbs up emoji

@FeLvi-zzz
Copy link
Author

@tagliala@javierjulio
I tried to add a spec inspec/unit/comments_spec.rb.
What do you two think about this?

@javierjuliojavierjulioforce-pushed thenot-to-register-activeadmin-comment-if-disabled branch from375a190 to34d50b3CompareOctober 5, 2025 16:00
@javierjulio
Copy link
Member

@mgrunberg@tagliala what do you think of the this approach and the tests? I think it would help to have as if the feature is not used then the routes should not exist and this seems to handle the case where it's only enabled for a specific namespace or resource. Any improvements or concerns?

FeLvi-zzz reacted with heart emoji

@codecov
Copy link

codecovbot commentedOct 5, 2025
edited
Loading

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.08%. Comparing base (f79eabd) to head (d81db47).

Additional details and impacted files
@@           Coverage Diff           @@##           master    #8710   +/-   ##=======================================  Coverage   99.08%   99.08%           =======================================  Files         139      139             Lines        4046     4047    +1     =======================================+ Hits         4009     4010    +1  Misses         37       37

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

🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tagliala
Copy link
Contributor

Sorry, I'm not familiar with the comments implementation.

I can see there is a global switch and a per-resource switch, so this is why it is not checking forconfig.comments = false.

I also assume that the global config can be override at namespace / model level, so you can havecomments false at global level, except for models or namespaces which explicitly set comments to true

I do not have suggestions for the specs

FeLvi-zzz reacted with thumbs up emoji

@mgrunberg
Copy link
Contributor

I'm not very familiar with the comments code either, but in a quick review, I'm ok with the approach and specs.

I'm just wondering if it's possible to reduce the usage of stubs/doubles. It's not a strong opinion. It's just that the spec has Namespace & Resource creation examples. I'm aware that we are trying to call a hook and the setup for that could not be easy.

FeLvi-zzz reacted with thumbs up emoji

@FeLvi-zzz
Copy link
Author

I reduced excessive stubs (thanks to@mgrunberg !).

Could anyone run tests?

@FeLvi-zzz
Copy link
Author

Oops, tests which I created look flaky...
I'll fix them 🙇

@tagliala
Copy link
Contributor

Hello, this is still failing. Can you also please rabse on master?

FeLvi-zzz reacted with thumbs up emoji

@FeLvi-zzzFeLvi-zzzforce-pushed thenot-to-register-activeadmin-comment-if-disabled branch fromcb979b8 tod81db47CompareNovember 1, 2025 05:35
Comment on lines +224 to +226
# Manually trigger the before_load, after_load event
ActiveSupport::Notifications.instrumentActiveAdmin::Application::BeforeLoadEvent,{active_admin_application:application}
ActiveSupport::Notifications.instrumentActiveAdmin::Application::AfterLoadEvent,{active_admin_application:application}
Copy link
Contributor

Choose a reason for hiding this comment

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

can't review here, I can'tell if this has side effects

Copy link
Author

Choose a reason for hiding this comment

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

I don't have any other ideas how to test this behavior without too many stubs, do you have the other better one?
If there is no way, many stubs or less ones, which is better?

ref.#8710 (comment)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@taglialataglialatagliala requested changes

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Bug: comment routes appear even when comments are disabled

4 participants

@FeLvi-zzz@tagliala@javierjulio@mgrunberg

[8]ページ先頭

©2009-2025 Movatter.jp