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

Spec for double query runtime increment #39

Conversation

pjdavis
Copy link

@pjdavis pjdavis commented Oct 7, 2022

Adds a spec around Lograge::ActiveRecordLogSubscriber#sql to ensure that when the config option keep_default_active_record_log is set, the ActiveRecord::LogSubscriber.runtime isn't incremented.

I tried to keep in style with what was already there, however it may be able to be accomplished in a better way and I'm happy to change if I need to.

Since the #sql method is calling both Rails and ActiveRecord, i just stubbed the constants in a before block with doubles. I didn't want to have to load in the entire framework just for the tests, and all I'm really concerned with is that the #runtime= method isn't called when the keep_default_active_record_log is truthy.

I added a require to the spec helper for active_record_log_subscriber, too. I don't think it's going to add much time at all to the spec startup, but I can move it somewhere else if that's desired.

I also targeted the merge to the issue-37/fix-double-query-runtime branch directly, since these tests will fail without the fix there.

Adds a spec around `Lograge::ActiveRecordLogSubscriber#sql` to ensure
that when the config option `keep_default_active_record_log` is set, the
`ActiveRecord::LogSubscriber.runtime` isn't incremented. This keeps
lograge from double-counting the total duration for database calls.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 7, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Owner

@iMacTia iMacTia left a comment

Choose a reason for hiding this comment

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

Thank you @pjdavis 🙏 !
This fell through the cracks and under other priorities, but thanks to you I should be able to revive it!

@iMacTia iMacTia merged commit 99b7f10 into iMacTia:issue-37/fix-double-query-runtime Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants