From 9340d4887fbf4638588bf3333bf4e1a8081fa805 Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Fri, 15 Nov 2013 15:29:53 +0200
Subject: [PATCH] Namespaces api specs

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
---
 spec/requests/api/namespaces_spec.rb | 31 ++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 spec/requests/api/namespaces_spec.rb

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
-- 
GitLab