2013-11-15 08:29:53 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2014-04-11 15:45:56 -04:00
|
|
|
describe API::API, api: true do
|
2013-11-15 08:29:53 -05:00
|
|
|
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")
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(response.status).to eq(401)
|
2013-11-15 08:29:53 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when authenticated as admin" do
|
|
|
|
it "admin: should return an array of all namespaces" do
|
|
|
|
get api("/namespaces", admin)
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(json_response).to be_an Array
|
2013-11-15 08:29:53 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(json_response.length).to eq(Namespace.count)
|
2013-11-15 08:29:53 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|