-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Skip redundant preference re-serialization on load #6502
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -387,6 +387,17 @@ class ComplexPreferableClass | |
| end | ||
| end | ||
|
|
||
| it "does not re-serialize unchanged preferences when read after load" do | ||
| loaded = PrefTest.find(@pt.id) | ||
|
|
||
| # NOTE: assigning preferences in after_initialize (even an identical value) flips | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [87/80] |
||
| # the attribute to "from user" state, so every later read re-dumps YAML. Skipping | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [87/80] |
||
| # the redundant assignment keeps reads on the cheaper "from database" path. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [81/80] |
||
| expect(Psych).not_to receive(:safe_dump) | ||
|
|
||
| loaded.preferences | ||
| end | ||
|
|
||
| it "clear preferences when record is deleted" do | ||
| @pt.save! | ||
| @pt.preferred_pref_test_pref = "lmn" | ||
|
|
||
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.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.