Conversation
❌ 97 blocking issues (100 total)
@qltysh one-click actions:
|
There was a problem hiding this comment.
After you reacted with a vomiting emoji to my CSP headers PR, I wanted my revenge. This was my moment, my intention was to be specially cruel here and destroy this PR and your self esteem. Regrettably, I actually like the PR. The only thing I dislike is having to create tens of empty classes. I left a few comments.
Also, the usage rules screen fails with the error:
undefined method `model_name' for class Settings
| return unless settings_params.key?(:enforce_sso) | ||
|
|
||
| return unless Settings.type_for_attribute('enforce_sso').cast(settings_params[:enforce_sso]) | ||
| settings.enforce_sso = settings_params[:enforce_sso] |
There was a problem hiding this comment.
We don't need to alter the in-memory the account settings here, we only need to cast the incoming value to evaluate it. We can use a new Setings instance for that.
There was a problem hiding this comment.
We need a new account object to get a working new settings instance. We can create a new EnforceSSO object and do something similar to the original version. But I think this approach reads much nicer.
Do you see any risks? I think claude originally used the casting approach and I found it too ugly.
There was a problem hiding this comment.
Mmm, I don't know, I don't like changing a value in the settings model, just for doing a check, just before updating that very model. I guess nothing can happen, but still. Uglyness is relative, on the other hand. IMO is better to use an approach that doesn't write on the settings model.
|
|
||
| validates :value, inclusion: { in: VALID_VALUES } | ||
|
|
||
| state_machine :value, initial: 'denied' do |
There was a problem hiding this comment.
I can't access the developer portal settings because of an undefined method:
NoMethodError (undefined method `multiple_applications_visible?' for an instance of Settings):
config/abilities/buyer_any.rb:38:in `block in <main>'
This state machine is not defining the method.
There was a problem hiding this comment.
wait, idea was to look at settings.rb and account_settings/* sorry, if I was not clear. I think that something broke by last iterations. Not ready for thoorough review. Just need to know if you see something bad on the hight level 😬
| @@ -0,0 +1,3 @@ | |||
| # frozen_string_literal: true | |||
|
|
|||
| class AccountSetting::JanrainRelyingParty < AccountSetting::StringSetting; end | |||
| @@ -0,0 +1,17 @@ | |||
| # frozen_string_literal: true | |||
|
|
|||
| class AccountSetting::StringSetting < AccountSetting | |||
There was a problem hiding this comment.
This one could be a subclass of TextSetting adding just the validation, right?
| switch_settings.each do |col| | ||
| type_name = col.to_s.camelize | ||
| execute <<~SQL.squish | ||
| INSERT INTO account_settings (account_id, type, value, tenant_id, created_at, updated_at) | ||
| SELECT account_id, | ||
| '#{type_name}', | ||
| #{col}, | ||
| tenant_id, | ||
| '#{now}', | ||
| '#{now}' | ||
| FROM settings | ||
| WHERE #{col} IS NOT NULL AND #{col} != '' | ||
| SQL |
There was a problem hiding this comment.
The code is the same for text, string and switch settings, no need to repeat the code three times.
| end | ||
|
|
||
| add_index :account_settings, [:account_id, :type], unique: true, name: 'index_account_settings_on_account_id_and_type' | ||
| add_index :account_settings, :account_id, name: 'index_account_settings_on_account_id' |
There was a problem hiding this comment.
This index is not needed because it's already included in the index above.
| # It's strongly recommended that you check this file into your version control system. | ||
|
|
||
| ActiveRecord::Schema[7.1].define(version: 2025_05_22_195407) do | ||
| ActiveRecord::Schema[7.1].define(version: 2026_02_28_120000) do |
There was a problem hiding this comment.
Fine, but we need schemas also for postgres and oracle.
| @@ -267,20 +267,22 @@ def setup | |||
| end | |||
|
|
|||
| test 'settings be created lazily for existing account' do | |||
There was a problem hiding this comment.
The behavior changes, the test name isn't valid anymore.
| # Ref: Rails Guides “Contributing to Ruby on Rails → Create an Executable Test Case” | ||
| # and typical AR issue examples that use this exact style. | ||
|
|
||
| begin |
There was a problem hiding this comment.
This doesn't seem should be part of the PR
jlledom
left a comment
There was a problem hiding this comment.
These are a few points that claude raised and I consider legit.
| has_one :profile, dependent: :delete | ||
| has_one :settings, dependent: :destroy, inverse_of: :account, autosave: true | ||
| lazy_initialization_for :profile, :settings, if: :should_not_be_deleted? | ||
| has_many :account_settings, dependent: :delete_all, inverse_of: :account, autosave: true |
There was a problem hiding this comment.
:delete_all skips callbacks, so audit logs won't be recorded. If we want to record logs for individual destruction of each setting when deleting the whole account, we should use :destroy, otherwise, it's fine.
| def transition_to(target) | ||
| target = target.to_s | ||
| return if value == target | ||
|
|
||
| case target | ||
| when 'denied' | ||
| deny! | ||
| when 'hidden' | ||
| value == 'denied' ? allow! : hide! | ||
| when 'visible' | ||
| allow! if value == 'denied' | ||
| show! | ||
| end | ||
| end | ||
|
|
||
| def typed_assign(raw_value) | ||
| transition_to(raw_value) | ||
| end |
There was a problem hiding this comment.
This implementation persists immediately instead of storing the changes in-memory and persist them when calling save. Is it intended? Could this cause any problem?
There was a problem hiding this comment.
This is a very good point. I need to investigate it.
|
This can be closed, right? |
|
No, I'm waiting for the pending header PRs to be merged as well the protected_attribute ones. I will then need to rebase. I don't want to compete with them as well better try them out before introducing bigger changes. |
No description provided.