diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/requests/api/groups_spec.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/requests/api/groups_spec.rb')
-rw-r--r-- | spec/requests/api/groups_spec.rb | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index fac9f4dfe00..da423e986c3 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -860,6 +860,66 @@ RSpec.describe API::Groups do end end + context 'with similarity ordering' do + let_it_be(:group_with_projects) { create(:group) } + let_it_be(:project_1) { create(:project, name: 'Project', path: 'project', group: group_with_projects) } + let_it_be(:project_2) { create(:project, name: 'Test Project', path: 'test-project', group: group_with_projects) } + let_it_be(:project_3) { create(:project, name: 'Test', path: 'test', group: group_with_projects) } + + let(:params) { { order_by: 'similarity', search: 'test' } } + + subject { get api("/groups/#{group_with_projects.id}/projects", user1), params: params } + + before do + group_with_projects.add_owner(user1) + end + + it 'returns items based ordered by similarity' do + subject + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to include_pagination_headers + expect(json_response.length).to eq(2) + + project_names = json_response.map { |proj| proj['name'] } + expect(project_names).to eq(['Test', 'Test Project']) + end + + context 'when `search` parameter is not given' do + before do + params.delete(:search) + end + + it 'returns items ordered by name' do + subject + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to include_pagination_headers + expect(json_response.length).to eq(3) + + project_names = json_response.map { |proj| proj['name'] } + expect(project_names).to eq(['Project', 'Test', 'Test Project']) + end + end + + context 'when `similarity_search` feature flag is off' do + before do + stub_feature_flags(similarity_search: false) + end + + it 'returns items ordered by name' do + subject + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to include_pagination_headers + expect(json_response.length).to eq(2) + + project_names = json_response.map { |proj| proj['name'] } + expect(project_names).to eq(['Test', 'Test Project']) + end + end + end + it "returns the group's projects with simple representation" do get api("/groups/#{group1.id}/projects", user1), params: { simple: true } @@ -1012,6 +1072,7 @@ RSpec.describe API::Groups do let!(:project4) do create(:project, namespace: group2, path: 'test_project', visibility_level: Gitlab::VisibilityLevel::PRIVATE) end + let(:path) { "/groups/#{group1.id}/projects/shared" } before do |