Commit ba169cc52d42425525921464070a513097a003ff
1 parent
a09fc160
Exists in
master
and in
4 other branches
API: projects/all tests
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
1 changed file
with
26 additions
and
0 deletions
Show diff stats
spec/requests/api/projects_spec.rb
@@ -36,6 +36,32 @@ describe API::API do | @@ -36,6 +36,32 @@ describe API::API do | ||
36 | end | 36 | end |
37 | end | 37 | end |
38 | 38 | ||
39 | + describe "GET /projects/all" do | ||
40 | + context "when unauthenticated" do | ||
41 | + it "should return authentication error" do | ||
42 | + get api("/projects/all") | ||
43 | + response.status.should == 401 | ||
44 | + end | ||
45 | + end | ||
46 | + | ||
47 | + context "when authenticated as regular user" do | ||
48 | + it "should return authentication error" do | ||
49 | + get api("/projects/all", user) | ||
50 | + response.status.should == 403 | ||
51 | + end | ||
52 | + end | ||
53 | + | ||
54 | + context "when authenticated as admin" do | ||
55 | + it "should return an array of all projects" do | ||
56 | + get api("/projects/all", admin) | ||
57 | + response.status.should == 200 | ||
58 | + json_response.should be_an Array | ||
59 | + json_response.first['name'].should == project.name | ||
60 | + json_response.first['owner']['email'].should == user.email | ||
61 | + end | ||
62 | + end | ||
63 | + end | ||
64 | + | ||
39 | describe "POST /projects" do | 65 | describe "POST /projects" do |
40 | context "maximum number of projects reached" do | 66 | context "maximum number of projects reached" do |
41 | before do | 67 | before do |