Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds support for displaying a “tombstone” overlay when a referenced resource has been deleted in collections or learning paths.
- Introduces fixtures and controller tests for learning paths, topics, and collections containing deleted items
- Updates views (
_learning_path_topic_item,_collection_item, new_deleted_resourcepartial) to conditionally render a tombstone instead of missing resources - Adds localization, CSS styles, Safe Navigation in models, and template changes for autocompleter
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/fixtures/*.yml | Added fixtures for paths, topics, collections with deleted items |
| test/controllers/*_controller_test.rb | New tests for show/edit/update when resource is deleted |
| config/locales/en.yml | Added deleted_resource localization key |
| app/views/common/_deleted_resource.html.erb | New partial for deleted-item overlay |
| app/views/learning_path_topic_items/_*.html.erb | Render deleted-item partial when resource is missing |
| app/views/collection_items/_*.html.erb | Ditto for collections |
| app/views/public_activity/common/_add_item.html.erb | Fallback title for deleted resource |
| app/views/collections/_collection_items_form.erb | JSON form: handle missing resource title and URL |
| app/assets/stylesheets/masonry.scss | Styles for .deleted-item-overlay |
| app/assets/javascripts/templates/*.hbs | Autocompleter: show muted span if no URL |
| app/models/*_item.rb | Use &. for resource title and guard secondary activity |
Comments suppressed due to low confidence (1)
test/fixtures/collection_items.yml:14
- [nitpick] Using a hardcoded large ID assumes the record doesn't exist, which can make tests brittle; consider using a fixture with no resource association or an explicit 'missing' fixture.
resource_id: 9999999 # Lets hope this doesn't exist
|
|
||
| get :show, params: { id: learning_path } | ||
| assert_response :success | ||
| assert_response :success |
There was a problem hiding this comment.
This assertion is duplicated; you can remove the extra assert_response :success for clarity.
| assert_response :success |
| <%= t('activity.actions.add') %> <%= type.model_name.human.downcase %> <%= link_to activity.parameters[:resource_title] || t('deleted_resource'), | ||
| polymorphic_path(type.model_name.singular.to_sym, | ||
| id: activity.parameters[:resource_id]) %> |
There was a problem hiding this comment.
[nitpick] Deleted resources are still rendered as links, which may lead to broken paths; consider rendering a non-clickable element (e.g. <span>) when the resource is missing.
| <%= t('activity.actions.add') %> <%= type.model_name.human.downcase %> <%= link_to activity.parameters[:resource_title] || t('deleted_resource'), | |
| polymorphic_path(type.model_name.singular.to_sym, | |
| id: activity.parameters[:resource_id]) %> | |
| <%= t('activity.actions.add') %> <%= type.model_name.human.downcase %> | |
| <% if activity.parameters[:resource_id].present? %> | |
| <%= link_to activity.parameters[:resource_title] || t('deleted_resource'), | |
| polymorphic_path(type.model_name.singular.to_sym, id: activity.parameters[:resource_id]) %> | |
| <% else %> | |
| <span><%= t('deleted_resource') %></span> | |
| <% end %> |
| <% learning_path_topic_item ||= nil %> | ||
| <% collection_item ||= learning_path_topic_item %> |
There was a problem hiding this comment.
[nitpick] The partial mixes learning_path_topic_item and collection_item, which can be confusing; consider passing a generic item local to simplify and clarify variable usage.
| <% learning_path_topic_item ||= nil %> | |
| <% collection_item ||= learning_path_topic_item %> | |
| <% item ||= nil %> |
Summary of changes
Motivation and context
#1108
Opted not to delete the
CollectionItem/LearningPathTopicItembecause there could be useful context in the comment.Screenshots
Checklist
to license it to the TeSS codebase under the
BSD license.