From be2c538d9ece95c6051cf5b3cdf1c2bea68b2635 Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Wed, 10 Jul 2013 16:55:03 -0700 Subject: [PATCH] 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