pass user info
This commit is contained in:
parent
e0c9fe993d
commit
a61f2fc04a
|
@ -37,6 +37,11 @@ module DiscourseAi
|
|||
).as_json,
|
||||
has_more: has_more,
|
||||
total_count: total_count,
|
||||
users:
|
||||
key_values
|
||||
.map { |kv| kv.user }
|
||||
.uniq
|
||||
.map { |u| BasicUserSerializer.new(u, root: nil).as_json },
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AiArtifactKeyValueSerializer < ApplicationSerializer
|
||||
attributes :id, :key, :value, :public, :created_at, :updated_at
|
||||
|
||||
has_one :user, serializer: BasicUserSerializer
|
||||
attributes :id, :key, :value, :public, :user_id, :created_at, :updated_at
|
||||
|
||||
def include_value?
|
||||
!options[:keys_only]
|
||||
|
|
|
@ -63,6 +63,12 @@ RSpec.describe DiscourseAi::AiBot::ArtifactKeyValuesController do
|
|||
)
|
||||
expect(json["has_more"]).to eq(false)
|
||||
expect(json["total_count"]).to eq(2)
|
||||
|
||||
expect(json["key_values"].map { |kv| kv["user_id"] }).to contain_exactly(
|
||||
user.id,
|
||||
other_user.id,
|
||||
)
|
||||
expect(json["users"].map { |u| u["id"] }).to contain_exactly(user.id, other_user.id)
|
||||
end
|
||||
|
||||
it "returns 404 for private artifact" do
|
||||
|
|
Loading…
Reference in New Issue