diff options
author | Rubén Dávila <ruben@gitlab.com> | 2018-07-17 00:48:39 -0500 |
---|---|---|
committer | Rubén Dávila <ruben@gitlab.com> | 2018-07-17 00:48:39 -0500 |
commit | dcae1cc908532bb0f8e12f446e542108b90ad59f (patch) | |
tree | 2db77cd8ef569896f2c44b93face70bffb10a995 | |
parent | 7f0431dd8550ac9d229d1383c03386c1634d015f (diff) | |
download | gitlab-ce-dcae1cc908532bb0f8e12f446e542108b90ad59f.tar.gz |
Add avatar_url attr to the response of the autocomplete endpoint
-rw-r--r-- | app/helpers/search_helper.rb | 6 | ||||
-rw-r--r-- | spec/helpers/search_helper_spec.rb | 14 |
2 files changed, 18 insertions, 2 deletions
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index f7dafca7834..cadb88ba632 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -105,7 +105,8 @@ module SearchHelper category: "Groups", id: group.id, label: "#{search_result_sanitize(group.full_name)}", - url: group_path(group) + url: group_path(group), + avatar_url: group.avatar_url || '' } end end @@ -119,7 +120,8 @@ module SearchHelper id: p.id, value: "#{search_result_sanitize(p.name)}", label: "#{search_result_sanitize(p.full_name)}", - url: project_path(p) + url: project_path(p), + avatar_url: p.avatar_url || '' } end end diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb index 6c9a7febf14..8bfd520528f 100644 --- a/spec/helpers/search_helper_spec.rb +++ b/spec/helpers/search_helper_spec.rb @@ -55,6 +55,20 @@ describe SearchHelper do expect(search_autocomplete_opts(project.name).size).to eq(1) end + it "includes the required project attrs" do + project = create(:project, namespace: create(:namespace, owner: user)) + result = search_autocomplete_opts(project.name).first + + expect(result.keys).to match_array(%i[category id value label url avatar_url]) + end + + it "includes the required group attrs" do + create(:group).add_owner(user) + result = search_autocomplete_opts("gro").first + + expect(result.keys).to match_array(%i[category id label url avatar_url]) + end + it "does not include the public group" do group = create(:group) expect(search_autocomplete_opts(group.name).size).to eq(0) |