summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/requests/api/namespaces_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/requests/api/namespaces_spec.rb b/spec/requests/api/namespaces_spec.rb
new file mode 100644
index 00000000000..2b1a4bf6ec8
--- /dev/null
+++ b/spec/requests/api/namespaces_spec.rb
@@ -0,0 +1,31 @@
+require 'spec_helper'
+
+describe API::API do
+ include ApiHelpers
+ before(:each) { ActiveRecord::Base.observers.enable(:user_observer) }
+ after(:each) { ActiveRecord::Base.observers.disable(:user_observer) }
+
+ 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
+
+ # Admin namespace + 2 group namespaces
+ json_response.length.should == 3
+ end
+ end
+ end
+end