Commit b9d40d2524a78013737be16b4cd0976ded843a1b
1 parent
5be0265f
Exists in
master
and in
4 other branches
Tests added to check status codes when handling milestone via API
A few more tests added to check status code when creating or updating milestones.
Showing
1 changed file
with
24 additions
and
0 deletions
Show diff stats
spec/requests/api/milestones_spec.rb
@@ -24,6 +24,11 @@ describe Gitlab::API do | @@ -24,6 +24,11 @@ describe Gitlab::API do | ||
24 | response.status.should == 200 | 24 | response.status.should == 200 |
25 | json_response['title'].should == milestone.title | 25 | json_response['title'].should == milestone.title |
26 | end | 26 | end |
27 | + | ||
28 | + it "should return a 404 error if milestone id not found" do | ||
29 | + get api("/projects/#{project.id}/milestones/1234", user) | ||
30 | + response.status.should == 404 | ||
31 | + end | ||
27 | end | 32 | end |
28 | 33 | ||
29 | describe "POST /projects/:id/milestones" do | 34 | describe "POST /projects/:id/milestones" do |
@@ -34,6 +39,19 @@ describe Gitlab::API do | @@ -34,6 +39,19 @@ describe Gitlab::API do | ||
34 | json_response['title'].should == 'new milestone' | 39 | json_response['title'].should == 'new milestone' |
35 | json_response['description'].should be_nil | 40 | json_response['description'].should be_nil |
36 | end | 41 | end |
42 | + | ||
43 | + it "should create a new project milestone with description and due date" do | ||
44 | + post api("/projects/#{project.id}/milestones", user), | ||
45 | + title: 'new milestone', description: 'release', due_date: '2013-03-02' | ||
46 | + response.status.should == 201 | ||
47 | + json_response['description'].should == 'release' | ||
48 | + json_response['due_date'].should == '2013-03-02' | ||
49 | + end | ||
50 | + | ||
51 | + it "should return a 400 error if title is missing" do | ||
52 | + post api("/projects/#{project.id}/milestones", user) | ||
53 | + response.status.should == 400 | ||
54 | + end | ||
37 | end | 55 | end |
38 | 56 | ||
39 | describe "PUT /projects/:id/milestones/:milestone_id" do | 57 | describe "PUT /projects/:id/milestones/:milestone_id" do |
@@ -43,5 +61,11 @@ describe Gitlab::API do | @@ -43,5 +61,11 @@ describe Gitlab::API do | ||
43 | response.status.should == 200 | 61 | response.status.should == 200 |
44 | json_response['title'].should == 'updated title' | 62 | json_response['title'].should == 'updated title' |
45 | end | 63 | end |
64 | + | ||
65 | + it "should return a 404 error if milestone is not found" do | ||
66 | + put api("/projects/#{project.id}/milestones/1234", user), | ||
67 | + title: 'updated title' | ||
68 | + response.status.should == 404 | ||
69 | + end | ||
46 | end | 70 | end |
47 | end | 71 | end |