Test more Ruby gaps; fix CMS export and conflict policy bugs - #12111
Merged
Merged
Conversation
- ExportCmsContentSetService: exporting with an inherited content set failed whenever an item also existed in it, because the comparison called String#strip on every attribute and pages (and others) have boolean attributes. Only strings are stripped now. - CmsContentLoaders::ConflictPolicies::Update: the same .strip on booleans (false&.strip still raises), and the fallback for items that weren't in the previous load called flat_map(&:keys) on a Hash, which yields [key, value] arrays, so it always raised. Also an item with no model in the database now just overwrites instead of being compared. Tests: ExportCmsContentSetService (including inheriting and a round trip through LoadCmsContentSetService), the Update conflict policy, SetupUserConProfileService, CalendarsController and SearchResult. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013mDr1nhgyzST2iPzCzMcCd
Contributor
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Tests for five Ruby areas that had little or no coverage, and fixes for two bugs in the CMS content tooling:
ExportCmsContentSetServicecrashed when exporting with an inherited content set. To skip items that are unchanged from the inherited version it compared attributes withtransform_values(&:strip), but items have boolean attributes (pages haveskip_clickwrap_agreement,hidden_from_search), sofalse.stripraised and the service returned a failed result. Any export that inherits from a set containing the same item (including the defaultinherit: ["standard"]) was affected. Only strings are stripped now.CmsContentLoaders::ConflictPolicies::Updatehad two bugs. (1) The same.stripon non-strings (false&.stripstill raises, since&.only guardsnil). (2) For an item that wasn't in the previous load,all_previous_content_keysdidprevious_content_by_identifier.flat_map(&:keys)on a Hash, which yields[key, value]arrays, so it always raisedNoMethodError: undefined method 'keys' for Array. Also an item with no model in the database now just overwrites rather than being compared. Nothing in the app instantiates this policy (it's an option to the loaders, presumably used from scripts), so the impact is limited.Tests (75 across the files below):
ExportCmsContentSetService: validation, metadata (root page, default layout, variables, navigation items), files written, inheriting (unchanged items skipped, whitespace ignored, edited items kept), root site export, and a round trip throughLoadCmsContentSetService. It writes to a temp directory.ConflictPolicies::Update: overwrite/skip decisions, whitespace, symbol keys, non-text attributes, skipped item messages, items missing from the previous load.SetupUserConProfileService: name,needs_update, form defaults, copying from earlier conventions of the same organization (most recent wins, gravatar, not from other organizations/people).CalendarsController: the iCal feed (name, timezone, event times/summary/description/url, waitlisted marker, title suffix, rooms, withdrawn signups excluded, wrong secret / other convention not found).SearchResult: events, pages, attendees and proposals by permission, limits and totals, hidden items, entry titles.I also cleared the existing rubocop offenses in the two service files I touched (the pre-commit hook won't let a touched file keep them): frozen string literal,
to_h, a memoized variable name, andsuper()in the policy's initializer.Testing
All new tests pass (75 tests, 135 assertions); rubocop clean on the touched files.
🤖 Generated with Claude Code
https://claude.ai/code/session_013mDr1nhgyzST2iPzCzMcCd