From 9d735dc27c09f0d9ce50711dbf99ddd8514f75b9 Mon Sep 17 00:00:00 2001 From: "Marko, Peter" Date: Thu, 14 Jun 2018 23:45:17 +0200 Subject: Ensure ordering for group sorting tests Instead of manually creating list to compare the test result, use system sort to assure no errors are introduced. Signed-off-by: Marko, Peter --- spec/requests/api/groups_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'spec/requests/api/groups_spec.rb') diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index 2e7a5cbeca6..f5218ebfac2 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -152,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, group4.name]) + expect(response_groups).to eq(Group.visible_to_user(user1).order(:name).pluck(:name)) end it "sorts in descending order when passed" do @@ -161,7 +161,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([group4.name, group1.name, group3.name]) + expect(response_groups).to eq(Group.visible_to_user(user1).order(name: :desc).pluck(:name)) end it "sorts by path in order_by param" do @@ -170,7 +170,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([group1.name, group4.name, group3.name]) + expect(response_groups).to eq(Group.visible_to_user(user1).order(:path).pluck(:name)) end it "sorts by id in the order_by param" do @@ -179,7 +179,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([group1.name, group3.name, group4.name]) + expect(response_groups).to eq(Group.visible_to_user(user1).order(:id).pluck(:name)) end end -- cgit v1.2.1