From 5236e6d4e726dfa0d9fc56df00f82707c6397849 Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Tue, 9 Jul 2013 18:15:11 -0700 Subject: [PATCH 01/11] Update travis-core to get Metadata changes --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 001a77e1..7fecb354 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -32,7 +32,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 95a2c894431665ca8ef3326d9504debbbc0f4f4a + revision: 67980733e69fbadd42d32ce1854194a2d96b1c3e specs: travis-core (0.0.1) actionmailer (~> 3.2.12) From b103a7ccb1f009ce18b08a4e698696133eee744c Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Tue, 9 Jul 2013 18:15:32 -0700 Subject: [PATCH 02/11] Add GET /jobs/:job_id/metadata endpoint --- lib/travis/api/app/endpoint/jobs.rb | 4 ++++ spec/integration/v2/jobs_spec.rb | 7 +++++++ spec/unit/endpoint/jobs_spec.rb | 6 +++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app/endpoint/jobs.rb b/lib/travis/api/app/endpoint/jobs.rb index 966ef7cd..c57436b4 100644 --- a/lib/travis/api/app/endpoint/jobs.rb +++ b/lib/travis/api/app/endpoint/jobs.rb @@ -28,6 +28,10 @@ class Travis::Api::App end end + get "/:job_id/metadata" do + respond_with service(:find_metadata, params) + end + def archive_url(path) "https://s3.amazonaws.com/#{hostname('archive')}#{path}" end diff --git a/spec/integration/v2/jobs_spec.rb b/spec/integration/v2/jobs_spec.rb index 4c7d202e..cd001a9e 100644 --- a/spec/integration/v2/jobs_spec.rb +++ b/spec/integration/v2/jobs_spec.rb @@ -75,4 +75,11 @@ describe 'Jobs' do end end end + + it "/jobs/:id/metadata" do + metadata_provider = Factory(:metadata_provider) + metadata = metadata_provider.metadata.create(job_id: job.id, description: "Foobar") + response = get "/jobs/#{job.id}/metadata", {}, headers + response.should deliver_json_for(Metadata.where(id: metadata.id), version: 'v2') + end end diff --git a/spec/unit/endpoint/jobs_spec.rb b/spec/unit/endpoint/jobs_spec.rb index 763f956a..70f288a9 100644 --- a/spec/unit/endpoint/jobs_spec.rb +++ b/spec/unit/endpoint/jobs_spec.rb @@ -1,5 +1,9 @@ require 'spec_helper' describe Travis::Api::App::Endpoint::Jobs do - it 'has to be tested' + let(:job) { Factory(:test) } + + it "GET /jobs/:id/metadata" do + get("/jobs/#{job.id}/metadata", {}, "HTTP_ACCEPT" => "application/vnd.travis-ci.2+json, */*; q=0.01").should be_ok + end end From 16a73d9e0b91594f097b69a88fc5540ca478c5af Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Tue, 9 Jul 2013 18:41:47 -0700 Subject: [PATCH 03/11] Add PUT /jobs/:id/metadata endpoint --- lib/travis/api/app/endpoint/jobs.rb | 12 ++++++++++++ spec/integration/v2/jobs_spec.rb | 27 ++++++++++++++++++++++++++- spec/unit/endpoint/jobs_spec.rb | 5 +++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app/endpoint/jobs.rb b/lib/travis/api/app/endpoint/jobs.rb index c57436b4..0cbbb346 100644 --- a/lib/travis/api/app/endpoint/jobs.rb +++ b/lib/travis/api/app/endpoint/jobs.rb @@ -32,6 +32,18 @@ class Travis::Api::App respond_with service(:find_metadata, params) end + put "/:job_id/metadata" do + if params[:description] + metadata = service(:update_metadata, params).run + + status metadata ? 204 : 401 + else + status 422 + + { "error" => "Must include a description" } + end + end + def archive_url(path) "https://s3.amazonaws.com/#{hostname('archive')}#{path}" end diff --git a/spec/integration/v2/jobs_spec.rb b/spec/integration/v2/jobs_spec.rb index cd001a9e..40adf972 100644 --- a/spec/integration/v2/jobs_spec.rb +++ b/spec/integration/v2/jobs_spec.rb @@ -76,10 +76,35 @@ describe 'Jobs' do end end - it "/jobs/:id/metadata" do + it "GET /jobs/:id/metadata" do metadata_provider = Factory(:metadata_provider) metadata = metadata_provider.metadata.create(job_id: job.id, description: "Foobar") response = get "/jobs/#{job.id}/metadata", {}, headers response.should deliver_json_for(Metadata.where(id: metadata.id), version: 'v2') end + + describe "PUT /jobs/:id/metadata" do + context "with valid credentials" do + it "responds with a 204" do + metadata_provider = Factory(:metadata_provider) + response = put "/jobs/#{job.id}/metadata", { username: metadata_provider.api_username, key: metadata_provider.api_key, description: "Foobar" }, headers + response.status.should eq(204) + end + end + + context "without a description" do + it "responds with a 422" do + metadata_provider = Factory(:metadata_provider) + response = put "/jobs/#{job.id}/metadata", { username: metadata_provider.api_username, key: metadata_provider.api_key }, headers + response.status.should eq(422) + end + end + + context "with invalid credentials" do + it "responds with a 401" do + response = put "/jobs/#{job.id}/metadata", { username: "invalid-username", key: "invalid-key", description: "Foobar" }, headers + response.status.should eq(401) + end + end + end end diff --git a/spec/unit/endpoint/jobs_spec.rb b/spec/unit/endpoint/jobs_spec.rb index 70f288a9..2a650439 100644 --- a/spec/unit/endpoint/jobs_spec.rb +++ b/spec/unit/endpoint/jobs_spec.rb @@ -2,8 +2,13 @@ require 'spec_helper' describe Travis::Api::App::Endpoint::Jobs do let(:job) { Factory(:test) } + let(:provider) { Factory(:metadata_provider) } it "GET /jobs/:id/metadata" do get("/jobs/#{job.id}/metadata", {}, "HTTP_ACCEPT" => "application/vnd.travis-ci.2+json, */*; q=0.01").should be_ok end + + it "PUT /jobs/:id/metadata" do + response = put("/jobs/#{job.id}/metadata", { "username" => provider.api_username, "key" => provider.api_key, "description" => "Foobar" }, "HTTP_ACCEPT" => "application/vnd.travis-ci.2+json, */*; q=0.01").should be_successful + end end From d92c4a0fdd7dfb0d0f2b1249df02e8dd01239e1b Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Wed, 10 Jul 2013 10:30:17 -0700 Subject: [PATCH 04/11] Update travis-core to get newest metadata changes --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7fecb354..061b5ed9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -32,7 +32,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 67980733e69fbadd42d32ce1854194a2d96b1c3e + revision: 5a9df95e5c04d03369e10b60f7e28ce1b2cf03b1 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) From be2c538d9ece95c6051cf5b3cdf1c2bea68b2635 Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Wed, 10 Jul 2013 16:55:03 -0700 Subject: [PATCH 05/11] Rename metadata => annotations --- lib/travis/api/app/endpoint/jobs.rb | 10 +++++----- spec/integration/v2/jobs_spec.rb | 22 +++++++++++----------- spec/unit/endpoint/jobs_spec.rb | 10 +++++----- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/travis/api/app/endpoint/jobs.rb b/lib/travis/api/app/endpoint/jobs.rb index 0cbbb346..a5e1d03f 100644 --- a/lib/travis/api/app/endpoint/jobs.rb +++ b/lib/travis/api/app/endpoint/jobs.rb @@ -28,15 +28,15 @@ class Travis::Api::App end end - get "/:job_id/metadata" do - respond_with service(:find_metadata, params) + get "/:job_id/annotations" do + respond_with service(:find_annotations, params) end - put "/:job_id/metadata" do + post "/:job_id/annotations" do if params[:description] - metadata = service(:update_metadata, params).run + annotation = service(:update_annotation, params).run - status metadata ? 204 : 401 + status annotation ? 204 : 401 else status 422 diff --git a/spec/integration/v2/jobs_spec.rb b/spec/integration/v2/jobs_spec.rb index 40adf972..6d69b0cc 100644 --- a/spec/integration/v2/jobs_spec.rb +++ b/spec/integration/v2/jobs_spec.rb @@ -76,33 +76,33 @@ describe 'Jobs' do end end - it "GET /jobs/:id/metadata" do - metadata_provider = Factory(:metadata_provider) - metadata = metadata_provider.metadata.create(job_id: job.id, description: "Foobar") - response = get "/jobs/#{job.id}/metadata", {}, headers - response.should deliver_json_for(Metadata.where(id: metadata.id), version: 'v2') + it "GET /jobs/:id/annotations" do + annotation_provider = Factory(:annotation_provider) + annotation = annotation_provider.annotations.create(job_id: job.id, description: "Foobar") + response = get "/jobs/#{job.id}/annotations", {}, headers + response.should deliver_json_for(Annotation.where(id: annotation.id), version: 'v2') end - describe "PUT /jobs/:id/metadata" do + describe "POST /jobs/:id/annotations" do context "with valid credentials" do it "responds with a 204" do - metadata_provider = Factory(:metadata_provider) - response = put "/jobs/#{job.id}/metadata", { username: metadata_provider.api_username, key: metadata_provider.api_key, description: "Foobar" }, headers + 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(204) end end context "without a description" do it "responds with a 422" do - metadata_provider = Factory(:metadata_provider) - response = put "/jobs/#{job.id}/metadata", { username: metadata_provider.api_username, key: metadata_provider.api_key }, headers + annotation_provider = Factory(:annotation_provider) + response = post "/jobs/#{job.id}/annotations", { username: annotation_provider.api_username, key: annotation_provider.api_key }, headers response.status.should eq(422) end end context "with invalid credentials" do it "responds with a 401" do - response = put "/jobs/#{job.id}/metadata", { username: "invalid-username", key: "invalid-key", description: "Foobar" }, headers + response = post "/jobs/#{job.id}/annotations", { username: "invalid-username", key: "invalid-key", 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 2a650439..30cc8ac0 100644 --- a/spec/unit/endpoint/jobs_spec.rb +++ b/spec/unit/endpoint/jobs_spec.rb @@ -2,13 +2,13 @@ require 'spec_helper' describe Travis::Api::App::Endpoint::Jobs do let(:job) { Factory(:test) } - let(:provider) { Factory(:metadata_provider) } + let(:provider) { Factory(:annotation_provider) } - it "GET /jobs/:id/metadata" do - get("/jobs/#{job.id}/metadata", {}, "HTTP_ACCEPT" => "application/vnd.travis-ci.2+json, */*; q=0.01").should be_ok + it "GET /jobs/:id/annotations" do + get("/jobs/#{job.id}/annotations", {}, "HTTP_ACCEPT" => "application/vnd.travis-ci.2+json, */*; q=0.01").should be_ok end - it "PUT /jobs/:id/metadata" do - response = put("/jobs/#{job.id}/metadata", { "username" => provider.api_username, "key" => provider.api_key, "description" => "Foobar" }, "HTTP_ACCEPT" => "application/vnd.travis-ci.2+json, */*; q=0.01").should be_successful + 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 end end From 921d6fbd6972201b5580e12177d5894463824892 Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Wed, 10 Jul 2013 16:56:03 -0700 Subject: [PATCH 06/11] Update core to get metadata->annotation rename --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 061b5ed9..21b07abf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -32,7 +32,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 5a9df95e5c04d03369e10b60f7e28ce1b2cf03b1 + revision: d57da369012458ccd513a5a91f20a807e50d41fd specs: travis-core (0.0.1) actionmailer (~> 3.2.12) From 8e1b19072566381e1d084a99a37103da32e4f507 Mon Sep 17 00:00:00 2001 From: Hiro Asari Date: Wed, 22 Jan 2014 07:50:30 -0500 Subject: [PATCH 07/11] Require status for updating Annotation and bump travis-core --- Gemfile.lock | 2 +- lib/travis/api/app/endpoint/jobs.rb | 4 ++-- spec/integration/v2/jobs_spec.rb | 16 ++++++++++++---- spec/unit/endpoint/jobs_spec.rb | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) 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 From 3f94ad877ed67ef1682042354e7abfa9d41fbeb2 Mon Sep 17 00:00:00 2001 From: Hiro Asari Date: Wed, 22 Jan 2014 14:06:59 -0500 Subject: [PATCH 08/11] Point travis-core to ref that works --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6ec9ee5a..8e000ce4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -23,7 +23,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: a5bdfab137229d4ec6b3135657596d5546ed11a6 + revision: 0e88e5cd27733f78a653137dc3a359da4c533264 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) From a92863675290e8b46ef32494e6bdaca77b35262b Mon Sep 17 00:00:00 2001 From: Hiro Asari Date: Wed, 22 Jan 2014 14:38:24 -0500 Subject: [PATCH 09/11] Bump travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8e000ce4..3ec8d5d9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -23,7 +23,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 0e88e5cd27733f78a653137dc3a359da4c533264 + revision: 142e630b16b772df1a20d5b8c3ffbeec9157997c specs: travis-core (0.0.1) actionmailer (~> 3.2.12) From f8089f06d4ee5bf09199e9758bfb498de4747cce Mon Sep 17 00:00:00 2001 From: Hiro Asari Date: Wed, 22 Jan 2014 14:45:48 -0500 Subject: [PATCH 10/11] Bump travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3ec8d5d9..14351f76 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -23,7 +23,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 142e630b16b772df1a20d5b8c3ffbeec9157997c + revision: 3da7a5ca49ec7db63cf34e9d72becc63c7b7392f specs: travis-core (0.0.1) actionmailer (~> 3.2.12) From 38da5f01ef19f3a26a50710f1cbda4ac99cd376f Mon Sep 17 00:00:00 2001 From: Hiro Asari Date: Wed, 22 Jan 2014 14:59:41 -0500 Subject: [PATCH 11/11] Bump travis-core Includes a recent merge --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 14351f76..6df423fa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -23,7 +23,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 3da7a5ca49ec7db63cf34e9d72becc63c7b7392f + revision: eab89c8ca2407790d9ba23c9150e976f2c3ef211 specs: travis-core (0.0.1) actionmailer (~> 3.2.12)