Commit 0ba699bb authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch 'issue_224176' into 'master'

Serialize reference attribute on epics autocomplete endpoint

See merge request gitlab-org/gitlab!49744
parents 665f575e 70f30086
......@@ -29,7 +29,10 @@ class Groups::AutocompleteSourcesController < Groups::ApplicationController
end
def epics
render json: @autocomplete_service.epics(confidential_only: params[:confidential_only])
render json: issuable_serializer.represent(
@autocomplete_service.epics(confidential_only: params[:confidential_only]),
parent_group: @group
)
end
def vulnerabilities
......
......@@ -34,7 +34,7 @@ module Groups
# See https://gitlab.com/gitlab-org/gitlab/issues/6837
EpicsFinder.new(current_user, finder_params)
.execute
.select(:iid, :title)
.select(:iid, :title, :group_id)
end
def vulnerabilities
......
......@@ -28,7 +28,7 @@ RSpec.describe Groups::AutocompleteSourcesController do
expect(json_response).to be_an(Array)
expect(json_response.first).to include(
'iid' => epic.iid, 'title' => epic.title
'iid' => epic.iid, 'title' => epic.title, 'reference' => epic.to_reference(epic.group)
)
end
end
......
......@@ -92,6 +92,8 @@ RSpec.describe Groups::AutocompleteService do
end
describe '#epics' do
let(:expected_attributes) { %i(iid title group_id) }
before do
stub_licensed_features(epics: true)
end
......@@ -105,16 +107,18 @@ RSpec.describe Groups::AutocompleteService do
end
it 'returns epics from group' do
expect(subject.epics.map(&:iid)).to contain_exactly(epic.iid)
result = subject.epics.map { |epic| epic.slice(expected_attributes) }
expect(result).to contain_exactly(epic.slice(expected_attributes))
end
it 'returns only confidential epics if confidential_only is true' do
confidential_epic = create(:epic, :confidential, group: group)
epics = subject.epics(confidential_only: true)
result = subject.epics(confidential_only: true)
.map { |epic| epic.slice(expected_attributes) }
expect(epics.map(&:iid)).to contain_exactly(confidential_epic.iid)
expect(epics.map(&:title)).to contain_exactly(confidential_epic.title)
expect(result).to contain_exactly(confidential_epic.slice(expected_attributes))
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment