Skip to content

FEATURE: Can edit category/host relationships for embedding#10

Open
everettbu wants to merge 1 commit into
rest-serializer-enhancement-pre-copilotfrom
rest-serializer-enhancement-post-copilot
Open

FEATURE: Can edit category/host relationships for embedding#10
everettbu wants to merge 1 commit into
rest-serializer-enhancement-pre-copilotfrom
rest-serializer-enhancement-post-copilot

Conversation

@everettbu

Copy link
Copy Markdown

Test 10

Copilot AI review requested due to automatic review settings July 26, 2025 19:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements the ability to edit category/host relationships for embedding functionality. It refactors the embedding system from a single site setting to a database-backed model with individual embeddable host records that can be associated with specific categories.

Key changes include:

  • Migration from site settings to EmbeddableHost model for managing embeddable hosts
  • Addition of admin UI for managing embeddable hosts and their category associations
  • Enhanced test infrastructure with new fabricators and improved test data

Reviewed Changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
app/models/embeddable_host.rb New model for managing embeddable hosts with category relationships
db/migrate/20150818190757_create_embeddable_hosts.rb Database migration to create embeddable_hosts table and migrate existing settings
app/controllers/admin/embeddable_hosts_controller.rb CRUD controller for managing embeddable hosts in admin interface
app/assets/javascripts/admin/components/embeddable-host.js.es6 Frontend component for editing individual embeddable hosts
app/assets/javascripts/discourse/models/store.js.es6 Enhanced store to handle plural ID relationships for embedded objects
spec/fabricators/embeddable_host_fabricator.rb Test fabricator for creating embeddable host test data
Multiple test files Updated to use new embeddable host model instead of site settings

@@ -0,0 +1,27 @@
Fabricator(:category) do

Copilot AI Jul 26, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is named 'embeddable_host_fabricator.rb' but contains category fabricators. The category fabricators should be in a separate file or this file should be renamed to reflect its actual content.

Copilot uses AI. Check for mistakes.
cat.update!(read_restricted: true)
cat.category_groups.build(group_id: transients[:group].id, permission_type: CategoryGroup.permission_types[:full])
end
Fabricator(:embeddable_host) do

Copilot AI Jul 26, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is named 'category_fabricator.rb' but contains an embeddable_host fabricator. The embeddable_host fabricator should be in a separate file or this file should be renamed appropriately.

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +7
self.host.sub!(/^https?:\/\//, '')
self.host.sub!(/\/.*$/, '')

Copilot AI Jul 26, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method sub! will raise a NoMethodError if self.host is nil. Consider using safe navigation or checking for nil before calling destructive string methods.

Suggested change
self.host.sub!(/^https?:\/\//, '')
self.host.sub!(/\/.*$/, '')
self.host&.sub!(/^https?:\/\//, '')
self.host&.sub!(/\/.*$/, '')

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +7
self.host.sub!(/^https?:\/\//, '')
self.host.sub!(/\/.*$/, '')

Copilot AI Jul 26, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method sub! will raise a NoMethodError if self.host is nil. Consider using safe navigation or checking for nil before calling destructive string methods.

Suggested change
self.host.sub!(/^https?:\/\//, '')
self.host.sub!(/\/.*$/, '')
self.host&.sub!(/^https?:\/\//, '')
self.host&.sub!(/\/.*$/, '')

Copilot uses AI. Check for mistakes.
Comment thread spec/models/topic_spec.rb
SiteSetting.embed_truncate = false
expect(topic.expandable_first_post?).to eq(false)
end
describe 'with an emeddable host' do

Copilot AI Jul 26, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a typo in 'emeddable' - it should be 'embeddable'.

Suggested change
describe 'with an emeddable host' do
describe 'with an embeddable host' do

Copilot uses AI. Check for mistakes.
Comment on lines 226 to +228
this.get('/fruits/:id', function() {
const fruit = fruits[0];

return response({ __rest_serializer: "1", fruit, farmers: [farmers[0]] });
return response({ __rest_serializer: "1", fruit, farmers, colors });

Copilot AI Jul 26, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The endpoint returns fruits[0] (apple) for any fruit ID, but the test expects fruit with ID 2 (banana). This should return the fruit that matches the requested ID.

Copilot uses AI. Check for mistakes.
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has been open for 60 days with no activity. To keep it open, remove the stale tag, push code, or add a comment. Otherwise, it will be closed in 14 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants