-
Notifications
You must be signed in to change notification settings - Fork 95
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
Wrap ActiveRecord::Base with ActiveSupport.on_load #199
Wrap ActiveRecord::Base with ActiveSupport.on_load #199
Conversation
Codecov Report
@@ Coverage Diff @@
## master #199 +/- ##
=======================================
Coverage 82.61% 82.61%
=======================================
Files 14 14
Lines 719 719
=======================================
Hits 594 594
Misses 125 125
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@nipe0324 thanks for your contribution.Could you add a test that covers this scenario? |
OK. Please give me a few days to add a test that covers this scenario. Thank you. |
@microsoft-github-policy-service agree |
Hi @nipe0324 I think you need a test for filters since this fix is about filters. By adding tests for filters
Thanks for your contribution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit tests are required
@nipe0324 Just giving a starting point, I prepared a prompt in ChatGPT. I didn't test it but I think test should be like below |
02bc01a
to
3b257b3
Compare
3b257b3
to
98809c7
Compare
require 'activerecord_multi_tenant' | ||
|
||
MultiTenantTest::Application.config.secret_token = 'x' * 40 | ||
MultiTenantTest::Application.config.secret_key_base = 'y' * 40 | ||
MultiTenantTest::Application.config.filter_parameters = [:password] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code should execute before ActiveRecord::Base
called. So, I moved to here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment explaining this necessity? Could you refer the test in the comment as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I commented.
@gurkanindibay Thanks a lot. I try to add filter test. Could you please confirm? |
require 'activerecord_multi_tenant' | ||
|
||
MultiTenantTest::Application.config.secret_token = 'x' * 40 | ||
MultiTenantTest::Application.config.secret_key_base = 'y' * 40 | ||
MultiTenantTest::Application.config.filter_parameters = [:password] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment explaining this necessity? Could you refer the test in the comment as well?
end | ||
|
||
MultiTenantTest::Application.config.secret_token = 'x' * 40 | ||
MultiTenantTest::Application.config.secret_key_base = 'y' * 40 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This 2 lines are not used. So I removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nipe0324 for your contribution :)
This PR try to fix #198
Cause
Before: Rails initialization order is NOT good.
First. Set
ActiveRecord::Base.filter_attributes
which is empty array.Second. Initialize
Rails.application.config.filter_parameters
After: Rails initialization order is good.
First. Initialize
Rails.application.config.filter_parameters
Second. Set
ActiveRecord::Base.filter_attributes
which is NOT empty array.Test
Use fixed gem
Run
bundle install
. And,bin/rails c
andfilter_parameters
works!!