Commit 9340d4887fbf4638588bf3333bf4e1a8081fa805
1 parent
0815098d
Exists in
master
and in
4 other branches
Namespaces api specs
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
1 changed file
with
31 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,31 @@ | @@ -0,0 +1,31 @@ | ||
1 | +require 'spec_helper' | ||
2 | + | ||
3 | +describe API::API do | ||
4 | + include ApiHelpers | ||
5 | + before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } | ||
6 | + after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } | ||
7 | + | ||
8 | + let(:admin) { create(:admin) } | ||
9 | + let!(:group1) { create(:group) } | ||
10 | + let!(:group2) { create(:group) } | ||
11 | + | ||
12 | + describe "GET /namespaces" do | ||
13 | + context "when unauthenticated" do | ||
14 | + it "should return authentication error" do | ||
15 | + get api("/namespaces") | ||
16 | + response.status.should == 401 | ||
17 | + end | ||
18 | + end | ||
19 | + | ||
20 | + context "when authenticated as admin" do | ||
21 | + it "admin: should return an array of all namespaces" do | ||
22 | + get api("/namespaces", admin) | ||
23 | + response.status.should == 200 | ||
24 | + json_response.should be_an Array | ||
25 | + | ||
26 | + # Admin namespace + 2 group namespaces | ||
27 | + json_response.length.should == 3 | ||
28 | + end | ||
29 | + end | ||
30 | + end | ||
31 | +end |