Commit 4416be54a90f9c7ecbf40e5bd6ca9b5ff1d8d26a
1 parent
c8e7d6df
Exists in
master
and in
4 other branches
API: specs for remove project
Showing
1 changed file
with
38 additions
and
0 deletions
Show diff stats
spec/requests/api/projects_spec.rb
| ... | ... | @@ -730,4 +730,42 @@ describe API::API do |
| 730 | 730 | end |
| 731 | 731 | end |
| 732 | 732 | end |
| 733 | + | |
| 734 | + describe "DELETE /projects/:id" do | |
| 735 | + context "when authenticated as user" do | |
| 736 | + it "should remove project" do | |
| 737 | + delete api("/projects/#{project.id}", user) | |
| 738 | + response.status.should == 200 | |
| 739 | + end | |
| 740 | + | |
| 741 | + it "should not remove a project if not an owner" do | |
| 742 | + user3 = create(:user) | |
| 743 | + project.team << [user3, :developer] | |
| 744 | + delete api("/projects/#{project.id}", user3) | |
| 745 | + response.status.should == 403 | |
| 746 | + end | |
| 747 | + | |
| 748 | + it "should not remove a non existing project" do | |
| 749 | + delete api("/projects/1328", user) | |
| 750 | + response.status.should == 404 | |
| 751 | + end | |
| 752 | + | |
| 753 | + it "should not remove a project not attached to user" do | |
| 754 | + delete api("/projects/#{project.id}", user2) | |
| 755 | + response.status.should == 404 | |
| 756 | + end | |
| 757 | + end | |
| 758 | + | |
| 759 | + context "when authenticated as admin" do | |
| 760 | + it "should remove any existing project" do | |
| 761 | + delete api("/projects/#{project.id}", admin) | |
| 762 | + response.status.should == 200 | |
| 763 | + end | |
| 764 | + | |
| 765 | + it "should not remove a non existing project" do | |
| 766 | + delete api("/projects/1328", admin) | |
| 767 | + response.status.should == 404 | |
| 768 | + end | |
| 769 | + end | |
| 770 | + end | |
| 733 | 771 | end | ... | ... |