diff --git a/Gemfile.lock b/Gemfile.lock index 7b578f37..6ec9ee5a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -23,7 +23,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: c251a6e0fa1c98723fa877a0bc4ee1d27190a12c + revision: a5bdfab137229d4ec6b3135657596d5546ed11a6 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) diff --git a/lib/travis/api/app/endpoint/jobs.rb b/lib/travis/api/app/endpoint/jobs.rb index 97a7b697..dec9ce34 100644 --- a/lib/travis/api/app/endpoint/jobs.rb +++ b/lib/travis/api/app/endpoint/jobs.rb @@ -69,14 +69,14 @@ class Travis::Api::App end post "/:job_id/annotations" do - if params[:description] + if params[:status] && params[:description] annotation = service(:update_annotation, params).run status annotation ? 204 : 401 else status 422 - { "error" => "Must include a description" } + { "error" => "Must include status and description" } end end diff --git a/spec/integration/v2/jobs_spec.rb b/spec/integration/v2/jobs_spec.rb index 8b3a1435..6e092e00 100644 --- a/spec/integration/v2/jobs_spec.rb +++ b/spec/integration/v2/jobs_spec.rb @@ -78,7 +78,7 @@ describe 'Jobs' do it "GET /jobs/:id/annotations" do annotation_provider = Factory(:annotation_provider) - annotation = annotation_provider.annotations.create(job_id: job.id, description: "Foobar") + annotation = annotation_provider.annotations.create(job_id: job.id, status: "passed", description: "Foobar") response = get "/jobs/#{job.id}/annotations", {}, headers response.should deliver_json_for(Annotation.where(id: annotation.id), version: 'v2') end @@ -87,7 +87,7 @@ describe 'Jobs' do context "with valid credentials" do it "responds with a 204" do annotation_provider = Factory(:annotation_provider) - response = post "/jobs/#{job.id}/annotations", { username: annotation_provider.api_username, key: annotation_provider.api_key, description: "Foobar" }, headers + response = post "/jobs/#{job.id}/annotations", { username: annotation_provider.api_username, key: annotation_provider.api_key, status: "passed", description: "Foobar" }, headers response.status.should eq(204) end end @@ -95,14 +95,22 @@ describe 'Jobs' do context "without a description" do it "responds with a 422" do annotation_provider = Factory(:annotation_provider) - response = post "/jobs/#{job.id}/annotations", { username: annotation_provider.api_username, key: annotation_provider.api_key }, headers + response = post "/jobs/#{job.id}/annotations", { username: annotation_provider.api_username, key: annotation_provider.api_key, status: "errored" }, headers + response.status.should eq(422) + end + end + + context "without a status" do + it "responds with a 422" do + annotation_provider = Factory(:annotation_provider) + response = post "/jobs/#{job.id}/annotations", { username: annotation_provider.api_username, key: annotation_provider.api_key, description: "Foobar" }, headers response.status.should eq(422) end end context "with invalid credentials" do it "responds with a 401" do - response = post "/jobs/#{job.id}/annotations", { username: "invalid-username", key: "invalid-key", description: "Foobar" }, headers + response = post "/jobs/#{job.id}/annotations", { username: "invalid-username", key: "invalid-key", status: "passed", description: "Foobar" }, headers response.status.should eq(401) end end diff --git a/spec/unit/endpoint/jobs_spec.rb b/spec/unit/endpoint/jobs_spec.rb index 30cc8ac0..23dc5636 100644 --- a/spec/unit/endpoint/jobs_spec.rb +++ b/spec/unit/endpoint/jobs_spec.rb @@ -9,6 +9,6 @@ describe Travis::Api::App::Endpoint::Jobs do end it "POST /jobs/:id/annotations" do - response = post("/jobs/#{job.id}/annotations", { "username" => provider.api_username, "key" => provider.api_key, "description" => "Foobar" }, "HTTP_ACCEPT" => "application/vnd.travis-ci.2+json, */*; q=0.01").should be_successful + response = post("/jobs/#{job.id}/annotations", { "username" => provider.api_username, "key" => provider.api_key, "status" => "passed", "description" => "Foobar" }, "HTTP_ACCEPT" => "application/vnd.travis-ci.2+json, */*; q=0.01").should be_successful end end