summaryrefslogtreecommitdiff
path: root/spec/requests/api/namespaces_spec.rb
blob: b8943ea0762fabcf8dee6eb9e22547d6edd20c9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'spec_helper'

describe API::API, api: true  do
  include ApiHelpers
  let(:admin) { create(:admin) }
  let!(:group1) { create(:group) }
  let!(:group2) { create(:group) }

  describe "GET /namespaces" do
    context "when unauthenticated" do
      it "should return authentication error" do
        get api("/namespaces")
        response.status.should == 401
      end
    end

    context "when authenticated as  admin" do
      it "admin: should return an array of all namespaces" do
        get api("/namespaces", admin)
        response.status.should == 200
        json_response.should be_an Array

        json_response.length.should == Namespace.count
      end
    end
  end
end