diff options
author | Marko, Peter <peter.marko@siemens.com> | 2018-06-08 20:37:19 +0200 |
---|---|---|
committer | Marko, Peter <peter.marko@siemens.com> | 2018-06-12 08:16:01 +0200 |
commit | 79033a5f678c05c640d0b0cb7b53909ae2b5e221 (patch) | |
tree | 65120efc093d2a35e50984b433f004242d904803 /spec | |
parent | a8da4f3fa810ed0931ee8f54ac8123fb2f484830 (diff) | |
download | gitlab-ce-79033a5f678c05c640d0b0cb7b53909ae2b5e221.tar.gz |
Add id group api sorting option
With introduction of subgroups, many groups may have the same
name and/or path, thus further sorting options are necessary.
Signed-off-by: Marko, Peter <peter.marko@siemens.com>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/api/groups_spec.rb | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index 7d923932309..2e7a5cbeca6 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -138,10 +138,12 @@ describe API::Groups do context "when using sorting" do let(:group3) { create(:group, name: "a#{group1.name}", path: "z#{group1.path}") } + let(:group4) { create(:group, name: "z#{group1.name}", path: "y#{group1.path}") } let(:response_groups) { json_response.map { |group| group['name'] } } before do group3.add_owner(user1) + group4.add_owner(user1) end it "sorts by name ascending by default" do @@ -150,7 +152,7 @@ describe API::Groups do expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array - expect(response_groups).to eq([group3.name, group1.name]) + expect(response_groups).to eq([group3.name, group1.name, group4.name]) end it "sorts in descending order when passed" do @@ -159,16 +161,25 @@ describe API::Groups do expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array - expect(response_groups).to eq([group1.name, group3.name]) + expect(response_groups).to eq([group4.name, group1.name, group3.name]) end - it "sorts by the order_by param" do + it "sorts by path in order_by param" do get api("/groups", user1), order_by: "path" expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array - expect(response_groups).to eq([group1.name, group3.name]) + expect(response_groups).to eq([group1.name, group4.name, group3.name]) + end + + it "sorts by id in the order_by param" do + get api("/groups", user1), order_by: "id" + + expect(response).to have_gitlab_http_status(200) + expect(response).to include_pagination_headers + expect(json_response).to be_an Array + expect(response_groups).to eq([group1.name, group3.name, group4.name]) end end |