diff options
author | Nick Thomas <nick@gitlab.com> | 2017-08-22 18:10:49 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2017-08-24 13:32:50 +0300 |
commit | 061472864ceaa4dc837eebcaa583f7b81d4e7e54 (patch) | |
tree | e760782a7247ca457edafe13de309e67364354ea /spec/requests/api/groups_spec.rb | |
parent | 502d6464b07154d74eecbeddbf2cd6dba841380f (diff) |
Fix group and project search for anonymous users
Diffstat (limited to 'spec/requests/api/groups_spec.rb')
-rw-r--r-- | spec/requests/api/groups_spec.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index 313c38cd29c..a7557c7fb22 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -20,10 +20,15 @@ describe API::Groups do describe "GET /groups" do context "when unauthenticated" do - it "returns authentication error" do + it "returns public groups" do get api("/groups") - expect(response).to have_http_status(401) + expect(response).to have_http_status(200) + expect(response).to include_pagination_headers + expect(json_response).to be_an Array + expect(json_response.length).to eq(1) + expect(json_response) + .to satisfy_one { |group| group['name'] == group1.name } end end @@ -165,6 +170,18 @@ describe API::Groups do end describe "GET /groups/:id" do + context 'when unauthenticated' do + it 'returns 404 for a private group' do + get api("/groups/#{group2.id}") + expect(response).to have_http_status(404) + end + + it 'returns 200 for a public group' do + get api("/groups/#{group1.id}") + expect(response).to have_http_status(200) + end + end + context "when authenticated as user" do it "returns one of user1's groups" do project = create(:project, namespace: group2, path: 'Foo') |