Skip to content

Commit

Permalink
chore(CE): Add resource link to catalogs controller (#530)
Browse files Browse the repository at this point in the history
Co-authored-by: TivonB-AI2 <[email protected]>
  • Loading branch information
github-actions[bot] and TivonB-AI2 authored Dec 16, 2024
1 parent 94b590b commit 3cd8cd6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/app/controllers/api/v1/catalogs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module V1
class CatalogsController < ApplicationController
include Catalogs
include AuditLogger
include ResourceLinkBuilder
before_action :set_connector, only: %i[create update]
before_action :set_catalog, only: %i[update]

Expand Down Expand Up @@ -70,7 +71,8 @@ def set_catalog

def create_audit_log
resource_id = params[:id] || params[:connector_id]
audit!(resource_id:, resource: @audit_resource, payload: @payload)
resource_link = build_link!(resource: @connector, resource_id: params[:connector_id])
audit!(resource_id:, resource: @audit_resource, payload: @payload, resource_link:)
end

def catalog_params
Expand Down
4 changes: 4 additions & 0 deletions server/spec/requests/api/v1/catalogs_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
expect(audit_log.resource_id).to eq(connector.id)
expect(audit_log.resource).to eq(connector.name)
expect(audit_log.workspace_id).to eq(workspace.id)
expect(audit_log.resource_link).to eq("/setup/destinations/#{connector.id}")
expect(audit_log.created_at).not_to be_nil
expect(audit_log.updated_at).not_to be_nil
end
Expand Down Expand Up @@ -125,6 +126,7 @@
expect(audit_log.resource_id).to eq(connector.id)
expect(audit_log.resource).to eq(connector.name)
expect(audit_log.workspace_id).to eq(workspace.id)
expect(audit_log.resource_link).to eq("/setup/destinations/#{connector.id}")
expect(audit_log.created_at).not_to be_nil
expect(audit_log.updated_at).not_to be_nil
end
Expand Down Expand Up @@ -176,6 +178,7 @@
expect(audit_log.resource_id).to eq(existing_catalog.id)
expect(audit_log.resource).to eq(connector.name)
expect(audit_log.workspace_id).to eq(workspace.id)
expect(audit_log.resource_link).to eq("/setup/destinations/#{connector.id}")
expect(audit_log.created_at).not_to be_nil
expect(audit_log.updated_at).not_to be_nil
end
Expand Down Expand Up @@ -206,6 +209,7 @@
expect(audit_log.resource_id).to eq(existing_catalog.id)
expect(audit_log.resource).to eq(connector.name)
expect(audit_log.workspace_id).to eq(workspace.id)
expect(audit_log.resource_link).to eq("/setup/destinations/#{connector.id}")
expect(audit_log.created_at).not_to be_nil
expect(audit_log.updated_at).not_to be_nil
end
Expand Down

0 comments on commit 3cd8cd6

Please sign in to comment.