diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 2ae186b967ab29d2c5f459ef516987d9fc1b46c0..e4cef6c587c0a702c30f90d6d8db01da3a65047b 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -36,6 +36,32 @@ describe API::API do end end + describe "GET /projects/all" do + context "when unauthenticated" do + it "should return authentication error" do + get api("/projects/all") + response.status.should == 401 + end + end + + context "when authenticated as regular user" do + it "should return authentication error" do + get api("/projects/all", user) + response.status.should == 403 + end + end + + context "when authenticated as admin" do + it "should return an array of all projects" do + get api("/projects/all", admin) + response.status.should == 200 + json_response.should be_an Array + json_response.first['name'].should == project.name + json_response.first['owner']['email'].should == user.email + end + end + end + describe "POST /projects" do context "maximum number of projects reached" do before do